Repository navigation
Expand file tree
/
Copy pathAccountTest.java
More file actions
76 lines (64 loc) · 1.85 KB
/
Copy pathAccountTest.java
File metadata and controls
76 lines (64 loc) · 1.85 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* The test class AccountTest.
*
* @author (your name)
* @version (a version number or a date)
*/
public class AccountTest
{
private Customer customer1;
private Transaction transact1;
private Transaction transact2;
private Transaction transact3;
private Account account1;
/**
* Default constructor for test class AccountTest
*/
public AccountTest()
{
}
/**
* Sets up the test fixture.
*
* Called before every test case method.
*/
@BeforeEach
public void setUp()
{
customer1 = new Customer("Fernando", "Alonso");
transact1 = new Transaction(200.00, "CREDIT", "ref1", new java.util.Date());
transact2 = new Transaction(100.00, "DEBIT", "ref2", new java.util.Date());
transact3 = new Transaction(300.00, "CREDIT", "ref3", new java.util.Date());
account1 = new Account(customer1, "12345");
account1.addTransaction(transact1);
account1.addTransaction(transact2);
account1.addTransaction(transact3);
}
/**
* Tears down the test fixture.
*
* Called after every test case method.
*/
@AfterEach
public void tearDown()
{
}
@Test
public void testAddTransaction()
{
Transaction transact4 = new Transaction(200.00, "CREDIT", "test", new java.util.Date());
account1.addTransaction(transact4);
assertEquals(4, account1.getNumberOfTransactions());
assertEquals(600.00, account1.getBalance(), 0.1);
assertEquals("test",account1.getTransactions()[3].getReference());
}
@Test
public void removeTransaction()
{
account1.removeTransaction("ref2");
}
}