AccountShould is failing for the right reasons.
authorGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 16:33:11 +0000 (17:33 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 16:33:11 +0000 (17:33 +0100)
We can now implement the printStatement method.

TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/TransactionRepository.java

index e5d4139..f6a8cea 100644 (file)
@@ -1,5 +1,7 @@
 package org.craftedsw.feature;
 
+import static java.util.Arrays.asList;
+import static org.mockito.BDDMockito.given;
 import static org.mockito.Mockito.verify;
 
 import java.util.List;
@@ -14,8 +16,8 @@ import org.mockito.runners.MockitoJUnitRunner;
 public class AccountShould {
 
        @Mock private TransactionRepository transactionRepository;
+       @Mock private StatementPrinter statementPrinter;
        private Account account;
-       private StatementPrinter statementPrinter;
 
        @Before
        public void initialise() {
@@ -38,7 +40,10 @@ public class AccountShould {
        
        @Test public void
        print_a_statement() {
-               List<Transaction> transactions = null;
+               List<Transaction> transactions = asList(new Transaction());
+               given(transactionRepository.allTransactions()).willReturn(transactions);
+               
+               account.printStatement();
                
                verify(statementPrinter).print(transactions);
        }
index 08e3ef7..499e87e 100644 (file)
@@ -1,5 +1,7 @@
 package org.craftedsw.feature;
 
+import java.util.List;
+
 public class TransactionRepository {
 
        public void addDeposit(int amount) {
@@ -10,4 +12,8 @@ public class TransactionRepository {
                throw new UnsupportedOperationException();
        }
 
+       public List<Transaction> allTransactions() {
+               throw new UnsupportedOperationException();
+       }
+
 }