PrintStatementeFeature requires the right values for clock.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Dec 2016 20:30:50 +0000 (21:30 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Dec 2016 22:30:55 +0000 (23:30 +0100)
TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Console.java
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java

index 64785e5..dc0c0e3 100644 (file)
@@ -3,7 +3,7 @@ package org.craftedsw.feature;
 public class Console {
 
        public void printLine(String text) {
-               throw new UnsupportedOperationException();
+               System.out.println(text);
        }
        
 }
index c11e331..f8f70ec 100644 (file)
@@ -1,5 +1,6 @@
 package org.craftedsw.feature;
 
+import static org.mockito.BDDMockito.given;
 import static org.mockito.Mockito.inOrder;
 
 import org.junit.Before;
@@ -24,12 +25,14 @@ public class PrintStatementFeature {
                // Acceptance test is using the real repository because the acceptance test
                // is testing the system as a whole. We are just mocking the external world (the Console)
                TransactionRepository transactionRepository = new TransactionRepository(clock); 
-               StatementPrinter statementPrinter = new StatementPrinter();
+               StatementPrinter statementPrinter = new StatementPrinter(console);
                account = new Account(transactionRepository, statementPrinter);
        }
        
        @Test public void
        print_statement_containing_all_transactions() {
+               given(clock.todayAsString()).willReturn("01/04/2014", "02/04/2014", "10/04/2014");
+               
                account.deposit(1000);
                // No negative value, instead we use the verb withdraw.
                // Semantics are very important in the code!!!
@@ -40,9 +43,9 @@ public class PrintStatementFeature {
                
                InOrder inOrder = inOrder(console);
                inOrder.verify(console).printLine("DATE | AMOUNT | BALANCE");
-               inOrder.verify(console).printLine("10 / 04 / 2014 | 500.00 | 1400.00");
-               inOrder.verify(console).printLine("02 / 04 / 2014 | -100.00 | 900.00");
-               inOrder.verify(console).printLine("01 / 04 / 2014 | 1000.00 | 1000.00");
+               inOrder.verify(console).printLine("10/04/2014 | 500,00 | 1400,00");
+               inOrder.verify(console).printLine("02/04/2014 | -100,00 | 900,00");
+               inOrder.verify(console).printLine("01/04/2014 | 1000,00 | 1000,00");
        }
 
 }