def test_given_aFranc_when_created_than_currency_accessible_readonly(self): x = MoneyFactory.franc(1) self.assertEqual('CHD', x.currency) x.currency = 'USD' self.assertNotEqual('USD', x.currency) self.assertEqual('CHD', x.currency)
def test_given_5CHD_and_5CHD_when_sum_than_return_10CHD(self): f1 = MoneyFactory.franc(5) f2 = MoneyFactory.franc(5) self.assertEqual(f1 + f2, MoneyFactory.franc(10))
def test_given_5franc_when_created_than_eq_5franc_and_neq_6franc(self): self.assertEqual(MoneyFactory.franc(5), MoneyFactory.franc(5)) self.assertNotEqual(MoneyFactory.franc(6), MoneyFactory.franc(5))
def test_given_5CHD_and_5CHD_when_reduced_by_bank_than_return_10CHD(self): f1 = MoneyFactory.franc(5) expression = f1 + f1 reduced_expression = expression.convert('CHD') self.assertEqual(reduced_expression, MoneyFactory.franc(10))
def test_given_10CHD_when_converted_to_USD_than_result_5USD(self): f1 = MoneyFactory.franc(10) self.assertEqual(f1.convert('USD'), MoneyFactory.dollar(5))
def test_given_aMoney_when_multiplied_2_than_result_doubled(self): x = MoneyFactory.franc(5) self.assertEqual(MoneyFactory.franc(10), x * 2)
def test_given_5franc_when_called_times2_than_eq_10franc(self): x = MoneyFactory.franc(5) self.assertEqual(x * 2, MoneyFactory.franc(10))
def test_given_5dollars_and_10francs_when_compared_result_equal(self): self.assertEqual(MoneyFactory.dollar(5), MoneyFactory.franc(10))
def test_given_5USD_and_10CHD_and_5USD_when_sum_than_result_15USD(self): f1 = MoneyFactory.franc(10) d1 = MoneyFactory.dollar(5) d2 = MoneyFactory.dollar(5) expression = (f1 + d1) + d2 self.assertEqual(MoneyFactory.dollar(15), expression)
def test_given_dollars_and_francs_when_compared_result_different(self): self.assertNotEqual(MoneyFactory.dollar(5), MoneyFactory.franc(5))
def test_given_aDollar_when_string_converted_than_print_amount_and_USD( self): x = MoneyFactory.dollar(5) self.assertEqual(str(x), "5USD")
def test_given_5USD_when_created_than_eq_5USD_and_neq_6USD(self): self.assertEqual(MoneyFactory.dollar(5), MoneyFactory.dollar(5)) self.assertNotEqual(MoneyFactory.dollar(6), MoneyFactory.dollar(5))
def test_given_5USD_when_called_times2_and_times3_than_eq_10USD(self): x = MoneyFactory.dollar(5) self.assertEqual(x * 3, MoneyFactory.dollar(15))
def test_given_5USD_and_5USD_when_sum_than_return_10USD(self): d1 = MoneyFactory.dollar(5) d2 = MoneyFactory.dollar(5) d3 = MoneyFactory.dollar(5) self.assertEqual(d1 + d2 + d3, MoneyFactory.dollar(15))