}
public void addWithdrawal(int amount) {
- throw new UnsupportedOperationException();
+ Transaction withdrawalTransaction = new Transaction(clock.todayAsString(), -amount);
+ transactions.add(withdrawalTransaction);
}
public List<Transaction> allTransactions() {
assertThat(transactions.size(), is(1));
assertThat(transactions.get(0), is(transaction(TODAY, 100)));
}
+
+ @Test public void
+ create_and_store_a_withdrawal_transaction() {
+ given(clock.todayAsString()).willReturn(TODAY);
+ transactionRepository.addWithdrawal(100);
+
+ List<Transaction> transactions = transactionRepository.allTransactions();
+
+ assertThat(transactions.size(), is(1));
+ assertThat(transactions.get(0), is(transaction(TODAY, -100)));
+ }
private Transaction transaction(String date, int amount) {
return new Transaction(date, amount);