def test_equality(self): """同一性テスト""" self.assertTrue(Money.dollar(5) == Money.dollar(5), "$5 == $5") self.assertFalse(Money.dollar(5) == Money.dollar(6), "$5 != $6") self.assertTrue(Money.franc(5) == Money.franc(5), "f5 == f5") self.assertFalse(Money.franc(5) == Money.franc(6), "f5 != f6") self.assertFalse(Money.franc(5) == Money.dollar(5), "f5 != $5")
def test_mixed_addition(self): five_bucks = Money.dollar(5) ten_francs = Money.franc(10) bank = Bank() bank.addRate("CHF", "USD", 2) result = bank.reduce(five_bucks.plus(ten_francs), "USD") assert Money.dollar(10) == result
def test_mixed_addition(self): five_bucks = Money.dollar(5) ten_franc = Money.franc(10) bank = Bank() bank.add_rate('CHF', 'USD', 2) result = bank.reduce(five_bucks.plus(ten_franc), 'USD') assert Money.dollar(10) == result
def test_mix_ed_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(Money.dollar(10), result)
def test_simple_addition(self): """同一単位の加算""" five = Money.dollar(5) total = five.plus(five) bank = Bank() reduced = bank.reduce(total, "USD") self.assertEqual(Money.dollar(10), reduced, "equal")
def test_sum_times(self): five_bucks = Money.dollar(5) ten_franc = Money.franc(10) bank = Bank() bank.add_rate('CHF', 'USD', 2) total = Total(five_bucks, ten_franc).times(2) result = bank.reduce(total, 'USD') assert Money.dollar(20) == result
def test_sum_plus_money(self): five_bucks = Money.dollar(5) ten_franc = Money.franc(10) bank = Bank() bank.add_rate('CHF', 'USD', 2) total = Total(five_bucks, ten_franc).plus(five_bucks) result = bank.reduce(total, 'USD') assert Money.dollar(15) == result
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(Money.dollar(20), result)
def test_SimpleAddition(self): assert Money.dollar(5).plus(Money.dollar(5)) == Money.dollar(10) five = Money.dollar(5) sumattion = five.plus(five) bank = Bank() reduced = bank.reduce(sumattion, "USD") assert Money.dollar(10) == reduced
def test_totalplus_money(self): """合計の加算""" five_bucks = Money.dollar(5) ten_francs = Money.franc(10) bank = Bank() bank.add_rate("CHF", "USD", 2) total = Total(five_bucks, ten_francs).plus(five_bucks) result = bank.reduce(total, "USD") self.assertEqual(Money.dollar(15), result)
def test_total_times(self): """moneyの倍""" five_bucks = Money.dollar(5) ten_francs = Money.franc(10) bank = Bank() bank.add_rate("CHF", "USD", 2) total = Total(five_bucks, ten_francs).times(2) result = bank.reduce(total, "USD") self.assertEqual(Money.dollar(20), result)
def test_plus_returnsum(self): """合計を返す場合のテスト""" five = Money.dollar(5) result = five.plus(five) total: Total = result self.assertEqual(five, total.augend()) self.assertEqual(five, total.addend())
def reduce(self, bank, to): from moneys.money import Money amount = ( self.augend.reduce(bank, to).amount + self.addend.reduce(bank, to).amount ) return Money(amount, to)
def test_ReduceMoney(self): bank = Bank() result = bank.reduce(Money.dollar(1), "USD") assert Money.dollar(1) == result
def test_ReduceSum(self): summation = Summation(Money.dollar(3), Money.dollar(4)) bank = Bank() result = bank.reduce(summation, "USD") assert result == Money.dollar(7)
def test_PlusReturnsSum(self): five = Money.dollar(5) result = five.plus(five) assert five == result.augend() assert five == result.addend()
def test_currency(self): assert Money.franc(1).currency() == "CHF" assert Money.dollar(1).currency() == "USD"
def test_reducemoney_diff_currency(self): """別の貨幣へ変換""" bank = Bank() bank.add_rate("CHF", "USD", 2) result = bank.reduce(Money.franc(2), "USD") self.assertEqual(Money.dollar(1), result)
def test_reduce_money(self): """Moneyのテスト""" bank = Bank() result = bank.reduce(Money.dollar(1), "USD") self.assertEqual(Money.dollar(1), result, "Money as expression")
def test_equality(self): assert Money.dollar(5) == Money.dollar(5) assert Money.dollar(5) != Money.dollar(6) assert Money.dollar(5) != Money.franc(5)
def test_currency(self): """通貨単位のテスト""" self.assertEqual("USD", Money.dollar(1).currency(), "Dollar Unit") self.assertEqual("CHF", Money.franc(1).currency(), "Franc Unit")
def test_reduce_sum(self): total = Total(Money.dollar(3), Money.dollar(4)) bank = Bank() result = bank.reduce(total, "USD") assert Money.dollar(7) == result
def test_franc_multiplication(self): """フランの計算""" five = Money.franc(5) self.assertEqual(Money.franc(10), five.times(2), "f10 == f10") self.assertEqual(Money.franc(15), five.times(3), "f15 == f15")
def test_currency(self): assert "USD" == Money.dollar(1).currency() assert "CHF" == Money.franc(1).currency()
def test_ReduceMoneyDifferentCurrency(self): bank = Bank() bank.addRate("CHF", "USD", 2) result = bank.reduce(Money.franc(2), "USD") assert Money.dollar(1) == result
def test_reducesum(self): """合計のテスト""" total = Total(Money.dollar(3), Money.dollar(4)) bank = Bank() result = bank.reduce(total, "USD") self.assertEqual(Money.dollar(7), result)
def test_simple_addition(self): five = Money.dollar(5) total = five.plus(five) bank = Bank() reduced = bank.reduce(total, 'USD') assert Money.dollar(10) == reduced
def test_reduce_money_different_currency(self): bank = Bank() bank.add_rate('CHF', 'USD', 2) result = bank.reduce(Money.franc(2), 'USD') assert Money.dollar(1) == result
def test_multiplication(self): """金額を指定倍する""" five: Money = Money.dollar(5) self.assertEqual(Money.dollar(10), five.times(2), "5 * 2") self.assertEqual(Money.dollar(15), five.times(3), "5 * 3")
def test_multiplication(self): five: Money = Money.dollar(5) assert Money.dollar(10) == five.times(2) assert Money.dollar(15) == five.times(3)