예제 #1
0
	def test_when_bills_are_unordered(self):
		batch = BatchBill([Bill(25), Bill(10), Bill(15), Bill(10)])
		desk = CashDesk()	
		desk.take_money(batch)
		expected = '10$ bills: 2\n15$ bills: 1\n25$ bills: 1\n'
		
		self.assertEqual(str(desk), expected)
예제 #2
0
	def test_take_no_bill(self):
		bill = None
		desk = CashDesk()
		expected_dict = {}

		desk.take_money(bill)

		self.assertEqual(desk.get_dict(), expected_dict)
예제 #3
0
	def test_take_batch(self):
		batch = BatchBill([Bill(5), Bill(10), Bill(15)])
		desk = CashDesk()
		expected_dict = {Bill(5): 1, Bill(10): 1, Bill(15): 1}

		desk.take_money(batch)

		self.assertEqual(desk.get_dict(), expected_dict)
예제 #4
0
	def test_take_one_bill(self):
		bill = Bill(10)
		desk = CashDesk()
		expected_dict = {Bill(10): 1}

		desk.take_money(bill)

		self.assertEqual(desk.get_dict(), expected_dict)
 def test_take_money_function_by_using_total_batch_test(self):
     values = [10, 20, 50, 100]
     bills = [Bill(value) for value in values]
     batch = BatchBill(bills)
     desk = CashDesk()
     desk.take_money(batch)
     result = desk.total()
     self.assertEqual(result, 180)
예제 #6
0
	def test_total_money(self):
		batch = BatchBill([Bill(5), Bill(10), Bill(15), Bill(10)])
		desk = CashDesk()	
		desk.take_money(batch)
		expected = 40

		result = desk.total()

		self.assertEqual(result, expected)
예제 #7
0
	def test_take_more_different_bills_consecutively(self):
		bill1 = Bill(10)
		bill2 = Bill(15)
		desk = CashDesk()
		expected_dict = {Bill(10): 1, Bill(15): 1}

		desk.take_money(bill1)
		desk.take_money(bill2)

		self.assertEqual(desk.get_dict(), expected_dict)
예제 #8
0
class TestCashDesk(unittest.TestCase):
    def setUp(self):
        self.bill = Bill(10)
        self.cash_desk = CashDesk()
        self.cash_desk.money = [Bill(5), Bill(20)]

    def test_take_money_method_with_a_Bill(self):
        self.cash_desk.take_money(self.bill)
        self.assertEqual(self.cash_desk.money, [Bill(5), Bill(20), Bill(10)])

    def test_take_money_method_with_a_Batch_of_Bills(self):
        values = [10, 20, 50]
        bills = [Bill(value) for value in values]
        batch = BatchBill(bills)
        self.cash_desk.take_money(batch)
        self.assertEqual(
            self.cash_desk.money,
            [Bill(5), Bill(20),
             Bill(10), Bill(20),
             Bill(50)])

    def test_take_money_method_with_invalid_argument(self):
        with self.assertRaises(TypeError):
            self.cash_desk.take_money('not Bill or BatchBill')

    def test_total_method_without_any_money(self):
        desk = CashDesk()
        self.assertEqual(desk.total(), 0)

    def test_total_method_with_money(self):
        self.assertEqual(self.cash_desk.total(), 25)
        self.cash_desk.take_money(Bill(100))
        self.assertEqual(self.cash_desk.total(), 125)

    def test___str___method_with_not_any_money(self):
        self.assertEqual(str(CashDesk()), '')

    def test___str___method_with_one_Bill(self):
        desk = CashDesk()
        desk.take_money(Bill(100))
        self.assertEqual(str(desk), '100$ bills - 1\n')

    def test___str___method(self):
        self.cash_desk.take_money(BatchBill([Bill(10), Bill(10), Bill(5)]))
        self.assertEqual(str(self.cash_desk), '5$ bills - 2\n'
                         '10$ bills - 2\n'
                         '20$ bills - 1\n')
        self.cash_desk.take_money(Bill(20))
        self.cash_desk.take_money(Bill(10))
        self.assertEqual(str(self.cash_desk), '5$ bills - 2\n'
                         '10$ bills - 3\n'
                         '20$ bills - 2\n')
예제 #9
0
 def test___str___method_with_one_Bill(self):
     desk = CashDesk()
     desk.take_money(Bill(100))
     self.assertEqual(str(desk), '100$ bills - 1\n')
 def test_can_withdraw_money_cant_withdraw(self):
     new_cash_desk = CashDesk()
     new_cash_desk.take_money({1: 2, 100: 3})
     self.assertFalse(new_cash_desk.can_withdraw_money(105))
 def test_can_withdraw_money_not_all_money(self):
     new_cash_desk = CashDesk()
     new_cash_desk.take_money({1: 2, 100: 3})
     self.assertTrue(new_cash_desk.can_withdraw_money(301))
 def test_total_after_money_take(self):
     new_cash_desk = CashDesk()
     new_cash_desk.take_money({1: 2, 100: 3})
     self.assertEqual(302, new_cash_desk.total())
 def test_take_money_function_by_using_total_bill_only_test(self):
     bill = Bill(10)
     desk = CashDesk()
     desk.take_money(bill)
     result = desk.total()
     self.assertEqual(result, 10)