From: Gustavo Martin Morcuende Date: Sun, 4 Dec 2016 16:41:58 +0000 (+0100) Subject: We have a green test for AccountShould X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=752706d6cef09cbb6088408d13de42e0a9ffeab2;p=JavaForFun We have a green test for AccountShould But PrintStatementFeature is failing because the acceptance test is using the real classes, it tells me what has not been implemented :) --- diff --git a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java index a24744b..226b949 100644 --- a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java +++ b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java @@ -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()); } } diff --git a/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java b/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java index f6a8cea..4a5b781 100644 --- a/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java +++ b/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/AccountShould.java @@ -21,7 +21,7 @@ public class AccountShould { @Before public void initialise() { - account = new Account(transactionRepository); + account = new Account(transactionRepository, statementPrinter); } @Test public void diff --git a/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java b/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java index ee1bfbb..48b180d 100644 --- a/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java +++ b/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java @@ -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