-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAccountTest.java
More file actions
35 lines (26 loc) · 1.03 KB
/
AccountTest.java
File metadata and controls
35 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ch.engenius.bank.Account;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AccountTest {
private Account testAccount;
@Before
public void setUp() {
testAccount = new Account(BigDecimal.valueOf(TestConstants.INITIAL_ACCOUNT_MONEY));
}
@Test
public void deposit_ShouldIncreaseAmount() {
testAccount.deposit(TestConstants.DEPOSIT_ACCOUNT_MONEY);
assertEquals(TestConstants.AFTER_DEPOSIT_ACCOUNT_MONEY, testAccount.getMoney().intValue());
}
@Test
public void withdraw_ShouldDecreaseAmount() {
testAccount.withdraw(TestConstants.WITHDRAW_ACCOUNT_MONEY);
assertEquals(TestConstants.AFTER_WITHDRAW_ACCOUNT_MONEY, testAccount.getMoney().intValue());
}
@Test(expected = IllegalStateException.class)
public void withdraw_ShouldThrowException_IfMoneyInsufficient() {
testAccount.withdraw(TestConstants.WITHDRAW_INSUFFICIENT_ACCOUNT_MONEY);
}
}