예제 #1
0
 def test_mixed_addition(self):
     five_bucks = Money.dollar(5)
     ten_francs = Money.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(five_bucks.plus(ten_francs), 'USD')
     self.assertEqual(result, Money.dollar(10))
예제 #2
0
 def test_sum_times(self):
     five_bucks = Money.dollar(5)
     ten_francs = Money.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     sum = Sum(five_bucks, ten_francs).times(2)
     result = bank.reduce(sum, 'USD')
     self.assertEqual(result, Money.dollar(20))
예제 #3
0
 def test_identity_rate(self):
     self.assertEqual(1, Bank().rate('USD', 'USD'))
예제 #4
0
 def test_reduce_money_different_currency(self):
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(Money.franc(2), 'USD')
     self.assertEqual(Money.dollar(1), result)
예제 #5
0
 def test_reduce_money(self):
     bank = Bank()
     result = bank.reduce(Money.dollar(1), 'USD')
     self.assertEqual(Money.dollar(1), result)
예제 #6
0
 def test_reduce_sum(self):
     sum = Sum(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(sum, 'USD')
     self.assertEqual(Money.dollar(7), result)
예제 #7
0
 def test_simple_addition(self):
     five = Money.dollar(5)
     sum = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(sum, "USD")
     self.assertEqual(Money.dollar(10), reduced)