def testMixedAddition(self): fiveBucks = Money.dollar(5) tenFrancs = Money.franc(10) bank = Bank() bank.addRate('CHF', 'USD', 2) result = bank.reduce(fiveBucks.plus(tenFrancs), 'USD') self.assertEqual(Money.dollar(10), result)
def testTotalTimes(self): fiveBucks = Money.dollar(5) tenFrancs = Money.franc(10) bank = Bank() bank.addRate('CHF', 'USD', 2) total = Total(fiveBucks, tenFrancs).times(2) result = bank.reduce(total, 'USD') self.assertEquals(Money.dollar(20), result)
def testSumTimes(self): fivedollar = Money.dollar(5) tenfranc = Money.franc(10) bank = Bank() bank.addRate('CHF', 'USD', 2) sum = Sum(fivedollar, tenfranc).times(2) result = bank.reduce(sum, 'USD') self.assertEqual(Money.dollar(20), result)
def testSumPlusMoney(self): fivedollar = Money.dollar(5) tenfranc = Money.franc(10) bank = Bank() bank.addRate('CHF', 'USD', 2) sum = Sum(fivedollar, tenfranc).plus(fivedollar) result = bank.reduce(sum, 'USD') self.assertEqual(Money.dollar(15), result)
def testReduceMoneyDifferentCurrency(self): bank = Bank() bank.addRate('CHF', 'USD', 2) result = bank.reduce(Money.franc(2), 'USD') self.assertEqual(Money.dollar(1), result)