move tests for tasks not implemented

This commit is contained in:
2026-03-17 11:31:51 +01:00
parent 285b61aa02
commit c79555e133
14 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
package oving7.abstractaccount;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class DebitAccountTest {
private static final double epsilon = 0.0005;
private DebitAccount sub;
@BeforeEach
public void setUp() {
sub = new DebitAccount();
}
@Test
@DisplayName("Check that deposits work as expected")
public void testDeposit() {
assertEquals(0.0, sub.getBalance(), epsilon, "The account balance was incorrect");
sub.deposit(10_000.0);
assertEquals(10_000.0, sub.getBalance(), epsilon, "The account balance was incorrect");
assertThrows(IllegalArgumentException.class, () -> {
sub.deposit(-10_000.0);
}, "Negative deposit should have triggered an IllegalArgumentException!");
assertEquals(10_000.0, sub.getBalance(), epsilon, "The account balance was incorrect");
}
@Test
@DisplayName("Check that withdrawals work as expected")
public void testWithdraw() {
sub.deposit(20_000.0);
sub.withdraw(5000.0);
assertEquals(15_000.0, sub.getBalance(), epsilon, "The account balance was incorrect");
assertThrows(IllegalArgumentException.class, () -> {
sub.withdraw(-10_000.0);
}, "Negative withdrawal should have triggered an IllegalArgumentException!");
assertEquals(15_000.0, sub.getBalance(), epsilon, "The account balance was incorrect");
assertThrows(IllegalArgumentException.class, () -> {
sub.withdraw(20_000.0);
}, "Withdrawal exceeding the balance should have triggered an IllegalArgumentException");
}
}