|
@@ -9,6 +9,7 @@ import static org.junit.Assert.*;
|
9
|
9
|
|
10
|
10
|
public class CheckbookTest {
|
11
|
11
|
Checkbook checkbook;
|
|
12
|
+ Checkbook checkbookNoOwner;
|
12
|
13
|
Transaction debit;
|
13
|
14
|
Transaction credit;
|
14
|
15
|
Payee payeeDebit;
|
|
@@ -26,6 +27,8 @@ public class CheckbookTest {
|
26
|
27
|
this.debit = new Transaction("This is a Debit", payeeDebit, TransactionType.DEBIT, 100.50);
|
27
|
28
|
this.credit = new Transaction("This is a Credit", payeeCredit, TransactionType.CREDIT, 100.50);
|
28
|
29
|
this.checkbook = new Checkbook(owner, 1000.00);
|
|
30
|
+
|
|
31
|
+ this.checkbookNoOwner = new Checkbook(100.50);
|
29
|
32
|
}
|
30
|
33
|
|
31
|
34
|
@Test
|
|
@@ -48,12 +51,14 @@ public class CheckbookTest {
|
48
|
51
|
@Test
|
49
|
52
|
public void test3Size(){
|
50
|
53
|
checkbook.add(debit);
|
|
54
|
+ checkbook.add(debit);
|
|
55
|
+ checkbook.add(debit);
|
51
|
56
|
checkbook.remove(debit);
|
52
|
|
- int expected = 0;
|
|
57
|
+ int expected = 2;
|
53
|
58
|
int actual = checkbook.size();
|
54
|
59
|
Assert.assertEquals(expected, actual);
|
55
|
60
|
}
|
56
|
|
-//
|
|
61
|
+
|
57
|
62
|
@Test
|
58
|
63
|
public void test1IsEmpty(){
|
59
|
64
|
checkbook.add(debit);
|
|
@@ -199,14 +204,35 @@ public class CheckbookTest {
|
199
|
204
|
|
200
|
205
|
@Test
|
201
|
206
|
public void test3ToArray(){
|
|
207
|
+ Transaction[] expected = new Transaction[1];
|
|
208
|
+ expected[0] = debit;
|
|
209
|
+ Transaction[] actual = checkbook.toArray(expected);
|
|
210
|
+ Assert.assertEquals(expected[0], actual[0]);
|
|
211
|
+ }
|
|
212
|
+
|
|
213
|
+ @Test
|
|
214
|
+ public void test1CheckbookValue(){
|
202
|
215
|
checkbook.add(debit);
|
|
216
|
+ double expected = 100.50;
|
|
217
|
+ double actual = checkbook.checkbookValue();
|
|
218
|
+ Assert.assertEquals(expected, actual);
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+ @Test
|
|
222
|
+ public void test2CheckbookValue(){
|
203
|
223
|
checkbook.add(credit);
|
204
|
|
- String expected = payeeCredit.getGivenName();
|
205
|
|
- Transaction[] ret = checkbook.toArray();
|
206
|
|
- String actual = ret[1].getPayee().getGivenName();
|
|
224
|
+ double expected = -100.50;
|
|
225
|
+ double actual = checkbook.checkbookValue();
|
207
|
226
|
Assert.assertEquals(expected, actual);
|
208
|
227
|
}
|
209
|
228
|
|
|
229
|
+ @Test
|
|
230
|
+ public void test3CheckbookValue(){
|
|
231
|
+ checkbook.add(credit);
|
|
232
|
+ double expected = -100.50;
|
|
233
|
+ double actual = checkbook.checkbookValue();
|
|
234
|
+ Assert.assertEquals(expected, actual);
|
|
235
|
+ }
|
210
|
236
|
|
211
|
237
|
|
212
|
238
|
|