コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 def testMultiplication(self):
     five = Money.dollar(5)
     self.assertEqual(Money.dollar(10), five.times(2))
     self.assertEqual(Money.dollar(15), five.times(3))
コード例 #6
0
 def testReduceMoneyDifferentCurrency(self):
     bank = Bank()
     bank.addRate('CHF', 'USD', 2)
     result = bank.reduce(Money.franc(2), 'USD')
     self.assertEqual(Money.dollar(1), result)
コード例 #7
0
 def testReduceMoney(self):
     bank = Bank()
     result = bank.reduce(Money.dollar(1), 'USD')
     self.assertEqual(Money.dollar(1), result)
コード例 #8
0
 def testReduceTotal(self):
     total = Total(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(total, 'USD')
     self.assertEqual(Money.dollar(7), result)
コード例 #9
0
 def testPlusReturnsTotal(self):
     five = Money.dollar(5)
     total = five.plus(five)
     self.assertEqual(five, total.augend)
     self.assertEqual(five, total.addend)
コード例 #10
0
 def testSimpleAddition(self):
     five = Money.dollar(5)
     total = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(total, 'USD')
     self.assertEqual(Money.dollar(10), reduced)
コード例 #11
0
 def testCurrency(self):
     self.assertEqual("USD", Money.dollar(1).currency)
     self.assertEqual("CHF", Money.franc(1).currency)
コード例 #12
0
 def testEquality(self):
     self.assertEqual(Money.dollar(5), Money.dollar(5))
     self.assertNotEqual(Money.dollar(5), Money.dollar(6))
     self.assertNotEqual(Money.franc(5), Money.dollar(5))
コード例 #13
0
 def testPlusSameCurrencyeturnMoney(self):
     sum = Money.dollar(1).plus(Money.dollar(1))
     bank = Bank()
     reduced = bank.reduce(sum, 'USD')
     self.assertEqual(isinstance(reduced, Money), True)
コード例 #14
0
 def testReduceSum(self):
     sum = Sum(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(sum, 'USD')
     self.assertEqual(Money.dollar(7), result)
コード例 #15
0
 def testPlusReturnsSum(self):
     five = Money.dollar(5)
     sum = five.plus(five)
     self.assertEqual(five, sum.augend)
     self.assertEqual(five, sum.addend)
コード例 #16
0
 def testCurrency(self):
     self.assertEqual('USD', Money.dollar(1).currency)
     self.assertEqual('CHF', Money.franc(1).currency)