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;
public class AccountShould {
@Mock private TransactionRepository transactionRepository;
+ @Mock private StatementPrinter statementPrinter;
private Account account;
- private StatementPrinter statementPrinter;
@Before
public void initialise() {
@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);
}
package org.craftedsw.feature;
+import java.util.List;
+
public class TransactionRepository {
public void addDeposit(int amount) {
throw new UnsupportedOperationException();
}
+ public List<Transaction> allTransactions() {
+ throw new UnsupportedOperationException();
+ }
+
}