We have a green test for AccountShould
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Dec 2016 16:41:58 +0000 (17:41 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 4 Dec 2016 22:30:02 +0000 (23:30 +0100)
But PrintStatementFeature is failing because the acceptance test is using
the real classes, it tells me what has not been implemented :)

TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java

index a24744b..226b949 100644 (file)
@@ -2,10 +2,13 @@ package org.craftedsw.feature;
 
 public class Account {
 
-       private TransactionRepository transactionRepository;
+       private final TransactionRepository transactionRepository;
+       private final StatementPrinter statementPrinter;
 
-       public Account(TransactionRepository transactionRepository) {
+       public Account(TransactionRepository transactionRepository,
+                       StatementPrinter statementPrinter) {
                this.transactionRepository = transactionRepository;
+               this.statementPrinter = statementPrinter;
        }
 
        public void deposit(int amount) {
@@ -17,5 +20,6 @@ public class Account {
        }
 
        public void printStatement() {
+               statementPrinter.print(transactionRepository.allTransactions());
        }
 }
index f6a8cea..4a5b781 100644 (file)
@@ -21,7 +21,7 @@ public class AccountShould {
 
        @Before
        public void initialise() {
-               account = new Account(transactionRepository);
+               account = new Account(transactionRepository, statementPrinter);
        }
        
        @Test public void
index ee1bfbb..48b180d 100644 (file)
@@ -20,7 +20,8 @@ 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(); 
-               account = new Account(transactionRepository);
+               StatementPrinter statementPrinter = new StatementPrinter();
+               account = new Account(transactionRepository, statementPrinter);
        }
        
        @Test public void