コード例 #1
0
 def test_mixed_addition(self):
     five_bucks = MoneyFactory.dollar(5)
     ten_francs = MoneyFactory.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(five_bucks.plus(ten_francs), 'USD')
     eq_(MoneyFactory.dollar(10), result)
コード例 #2
0
 def test_mixed_addition(self):
     five_bucks: Expression = Money.dollar(5)
     ten_franc: Expression = Money.franc(10)
     bank = Bank()
     bank.add_rate("CHF", "USD", 2)
     result = bank.reduce(five_bucks.plus(ten_franc), "USD")
     self.assertEqual(Money.dollar(10), result)
コード例 #3
0
 def test_sum_times(self):
     five_bucks = MoneyFactory.dollar(5)
     ten_francs = MoneyFactory.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     sum_ = Sum(five_bucks, ten_francs).times(2)
     result = bank.reduce(sum_, 'USD')
     eq_(MoneyFactory.dollar(20), result)
コード例 #4
0
 def test_sum_plus_money(self):
     five_bucks = MoneyFactory.dollar(5)
     ten_francs = MoneyFactory.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     sum_ = Sum(five_bucks, ten_francs).plus(five_bucks)
     result = bank.reduce(sum_, 'USD')
     eq_(MoneyFactory.dollar(15), result)
コード例 #5
0
 def test_sum_times(self):
     five_bucks: Expression = Money.dollar(5)
     ten_franc: Expression = Money.franc(10)
     bank = Bank()
     bank.add_rate("CHF", "USD", 2)
     cul_sum = Sum(five_bucks, ten_franc).times(2)
     result = bank.reduce(cul_sum, "USD")
     self.assertEqual(Money.dollar(20), result)
コード例 #6
0
 def test_reduce_money_different_currency(self):
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(MoneyFactory.franc(2), 'USD')
     eq_(MoneyFactory.dollar(1), result)