The acceptance test is failing because we need to implement the print method in State...
authorGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 18:49:14 +0000 (19:49 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 18:49:14 +0000 (19:49 +0100)
We always write first a test and then the implementation.
In this case we have to create the test called StatementPrinterShould and from
there we can create the implementation for the print method.

TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/StatementPrinter.java
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/StatementPrinterShould.java [new file with mode: 0644]

index d09be2f..717ec3c 100644 (file)
@@ -4,8 +4,14 @@ import java.util.List;
 
 public class StatementPrinter {
 
+       private final Console console;
+
+       public StatementPrinter(Console console) {
+               this.console = console;
+       }
+
        public void print(List<Transaction> transactions) {
-               throw new UnsupportedOperationException();
+               console.printLine("DATE | AMOUNT | BALANCE");
        }
 
 }
diff --git a/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/StatementPrinterShould.java b/TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/StatementPrinterShould.java
new file mode 100644 (file)
index 0000000..01bc876
--- /dev/null
@@ -0,0 +1,28 @@
+package org.craftedsw.feature;
+
+import static org.mockito.Mockito.verify;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class StatementPrinterShould {
+
+       private static final List<Transaction> NO_TRANSACTIONS = Collections.emptyList();
+       @Mock private Console console;
+
+       @Test public void
+       always_print_the_header() {
+               StatementPrinter statementPrinter = new StatementPrinter(console);
+               
+               statementPrinter.print(NO_TRANSACTIONS);
+               
+               verify(console).printLine("DATE | AMOUNT | BALANCE");
+       }
+
+}