From 752706d6cef09cbb6088408d13de42e0a9ffeab2 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 4 Dec 2016 17:41:58 +0100 Subject: [PATCH] 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 :) --- .../bank/src/main/java/org/craftedsw/feature/Account.java | 8 ++++++-- .../bank/src/test/java/org/craftedsw/feature/AccountShould.java | 2 +- .../test/java/org/craftedsw/feature/PrintStatementFeature.java | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) 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 -- 2.1.4