}
}
@Test
public void itHasTheCorrectBalancesForAllTxactions() throws Exception {
TxactionBalanceCalculator calculator = calculator();
// initial balances:
// checking = 90 USD
// credit = -50 USD
// cash = n/a
// savings = 800 USD (1000 EUR * 0.8 USD / EUR)
// total = 840 USD
assertEquals(money("840.00", USD), calculator.getBalance(newerThanFirstBalance));
// adjust checking balance: 90 - (-10) => 100 (total 850)
assertEquals(money("850.00", USD), calculator.getBalance(firstTxactionPastFirstBalance));
// adjust checking balance: 100 - (-10) => 110 (total 860)
assertEquals(money("860.00", USD), calculator.getBalance(secondTxactionPastFirstBalance));
// adjust credit balance: -50 - (-20) => -30 (total 880)
assertEquals(money("880.00", USD), calculator.getBalance(thirdTxactionPastFirstBalance));
// adjust credit balance: -30 - (-20) => -10 (total 900)
assertEquals(money("900.00", USD), calculator.getBalance(cashTxaction));
// REVIEW <brian@wesabe.com> 2009-04-08: Should the balance for cash transactions be null?
// no adjustment of balance (total 900)
assertEquals(money("900.00", USD), calculator.getBalance(fifthTxactionPastFirstBalance));
// adjust savings balance: 1000 EUR - (100 EUR) => 900 EUR => 720 USD (total 820)
assertEquals(money("820.00", USD), calculator.getBalance(sixthTxactionPastFirstBalance));
// adjust savings balance: 900 EUR - (100 EUR) => 800 EUR => 640 USD (total 740)
assertEquals(money("740.00", USD), calculator.getBalance(firstTxactionAfterCreditIsReset));
// adjust credit balance: 0 - (400) => -400 (total 340)
assertEquals(money("340.00", USD), calculator.getBalance(lastTxaction));
// adjust savings balance: 800 EUR - (100 EUR) => 700 EUR => 560 USD (total 260)
}