瀏覽代碼

test3CheckbookValue

Nick Satinover 6 年之前
父節點
當前提交
554e33e113
共有 1 個文件被更改,包括 113 次插入0 次删除
  1. 113
    0
      Checkbook/src/test/java/CheckbookTest.java

+ 113
- 0
Checkbook/src/test/java/CheckbookTest.java 查看文件

3
 
3
 
4
 import javax.swing.text.html.HTMLDocument;
4
 import javax.swing.text.html.HTMLDocument;
5
 
5
 
6
+import java.time.LocalDate;
6
 import java.util.stream.Stream;
7
 import java.util.stream.Stream;
7
 
8
 
8
 import static org.junit.Assert.*;
9
 import static org.junit.Assert.*;
234
         Assert.assertEquals(expected, actual);
235
         Assert.assertEquals(expected, actual);
235
     }
236
     }
236
 
237
 
238
+//    @Test
239
+//    public void test1GetTransactionsForDate(){
240
+//        checkbook.add(credit);
241
+//        checkbook.add(debit);
242
+//        Transaction[] retarr = checkbook.getTransactionsForDate(LocalDate.now());
243
+//        Transaction expected = credit;
244
+//        Assert.assertEquals(expected, retarr[1]);
245
+//    }
237
 
246
 
247
+    @Test
248
+    public void test1GetAllTransactionsForPayee(){
249
+        checkbook.add(debit);
250
+        checkbook.add(credit);
251
+        checkbook.add(credit);
252
+        checkbook.add(debit);
253
+        Payee expected = debit.getPayee();
254
+        Transaction[] arr = checkbook.getAllTransactionsForPayee(payeeDebit);
255
+        Payee actual = arr[0].getPayee();
256
+        Payee actual2 = arr[1].getPayee();
257
+        Assert.assertEquals(expected, actual);
258
+        Assert.assertEquals(expected, actual2);
259
+    }
260
+
261
+    @Test
262
+    public void test2GetAllTransactionsForPayee(){
263
+        checkbook.add(debit);
264
+        checkbook.add(credit);
265
+        checkbook.add(credit);
266
+        Payee expected = credit.getPayee();
267
+        Transaction[] arr = checkbook.getAllTransactionsForPayee(payeeCredit);
268
+        Payee actual = arr[0].getPayee();
269
+        Payee actual2 = arr[1].getPayee();
270
+        Assert.assertEquals(expected, actual);
271
+        Assert.assertEquals(expected, actual2);
272
+    }
273
+
274
+    @Test
275
+    public void test3GetAllTransactionsForPayee(){
276
+        checkbook.add(debit);
277
+        checkbook.add(credit);
278
+        Payee expected = credit.getPayee();
279
+        Transaction[] arr = checkbook.getAllTransactionsForPayee(payeeCredit);
280
+        Payee actual = arr[0].getPayee();
281
+        Assert.assertEquals(expected, actual);
282
+    }
283
+
284
+    @Test
285
+    public void test1GetAllDebitTransactions(){
286
+        checkbook.add(debit);
287
+        checkbook.add(credit);
288
+        Transaction expected = debit;
289
+        Transaction[] arr = checkbook.getAllDebitTransactions();
290
+        Transaction actual = arr[0];
291
+        Assert.assertEquals(expected, actual);
292
+    }
293
+
294
+    @Test
295
+    public void test2GetAllDebitTransactions(){
296
+        checkbook.add(debit);
297
+        checkbook.add(credit);
298
+        checkbook.add(debit);
299
+        checkbook.add(debit);
300
+        Transaction expected = debit;
301
+        Transaction[] arr = checkbook.getAllDebitTransactions();
302
+        Transaction actual = arr[0];
303
+        Transaction actual2 = arr[1];
304
+        Transaction actual3 = arr[2];
305
+        Assert.assertEquals(expected, actual);
306
+        Assert.assertEquals(expected, actual2);
307
+        Assert.assertEquals(expected, actual3);
308
+    }
309
+
310
+    @Test
311
+    public void test3GetAllDebitTransactions(){
312
+        checkbook.add(credit);
313
+        boolean expected = true;
314
+        Transaction[] arr = checkbook.getAllDebitTransactions();
315
+        boolean actual = arr.length == 0;
316
+        Assert.assertEquals(expected, actual);
317
+    }
238
 
318
 
319
+    @Test
320
+    public void test1GetAllCreditTransactions(){
321
+        checkbook.add(debit);
322
+        checkbook.add(credit);
323
+        Transaction expected = credit;
324
+        Transaction[] arr = checkbook.getAllCreditTransactions();
325
+        Transaction actual = arr[0];
326
+        Assert.assertEquals(expected, actual);
327
+    }
328
+
329
+    @Test
330
+    public void test2GetAllCreditTransactions(){
331
+        checkbook.add(debit);
332
+        checkbook.add(credit);
333
+        checkbook.add(debit);
334
+        checkbook.add(debit);
335
+        Transaction expected = credit;
336
+        int expected2 = 1;
337
+        Transaction[] arr = checkbook.getAllCreditTransactions();
338
+        Transaction actual = arr[0];
339
+        int actual2 = arr.length;
340
+        Assert.assertEquals(expected, actual);
341
+        Assert.assertEquals(expected2, actual2);
342
+    }
343
+
344
+    @Test
345
+    public void test3GetAllCreditTransactions(){
346
+        checkbook.add(debit);
347
+        boolean expected = true;
348
+        Transaction[] arr = checkbook.getAllCreditTransactions();
349
+        boolean actual = arr.length == 0;
350
+        Assert.assertEquals(expected, actual);
351
+    }
239
 
352
 
240
 
353
 
241
     @org.junit.After
354
     @org.junit.After