Esempio n. 1
0
    def test_list_to_marbles(self):
        # arrange
        test_list = [3, 77, 9, 8]

        # act
        result = marbles_to_list(list_to_marbles(test_list))

        # assert
        self.assertEqual(result, test_list)
Esempio n. 2
0
    def test_remove_marble_removes_marble(self):
        # arrange
        test_list = [4, 7, 88, 9, 11]
        first_marble = list_to_marbles(test_list)
        marble = first_marble.next_n(2)

        # act
        remove_marble(marble)

        # assert
        result = marbles_to_list(first_marble)
        self.assertEqual(result, [4, 7, 9, 11])
Esempio n. 3
0
    def test_insert_marble_after(self):
        # arrange
        test_list = [4, 7, 88, 9, 11]
        first_marble = list_to_marbles(test_list)
        marble = first_marble.next_n(2)

        # act
        insert_marble_after(marble, 5)

        # assert
        result = marbles_to_list(first_marble)
        self.assertEqual(result, [4, 7, 88, 5, 9, 11])
Esempio n. 4
0
    def test_remove_marble_returns_marble(self):
        # arrange
        test_list = [4, 7, 88, 9, 11]
        first_marble = list_to_marbles(test_list)
        marble = first_marble.next_n(2)

        # act
        result = remove_marble(marble)

        # assert
        self.assertEqual(result, marble)
        self.assertEqual(result.next, result)
        self.assertEqual(result.prev, result)
Esempio n. 5
0
    def test_play_round_first(self):
        # arrange
        marbles_list = [0]
        marble = list_to_marbles(marbles_list)
        next_marble_value = 1

        # act
        (score, current_marble) = play_round(marble, next_marble_value)

        # assert
        marbles_list = marbles_to_list(marble)
        self.assertEqual(marbles_list, [0, 1])
        self.assertEqual(score, 0)
        self.assertEqual(current_marble.value, 1)
Esempio n. 6
0
    def test_play_round_second(self):
        # arrange
        marbles_list = [0, 1]
        marble = list_to_marbles(marbles_list)
        current_marble = marble.next
        next_marble_value = 2

        # act
        (score, current_marble) = play_round(current_marble, next_marble_value)

        # assert
        result = marbles_to_list(marble)
        self.assertEqual(result, [0, 2, 1])
        self.assertEqual(score, 0)
        self.assertEqual(current_marble.value, 2)
Esempio n. 7
0
    def test_play_round_typical_round(self):
        # arrange
        marbles_list = [0, 8, 4, 9, 2, 10, 5, 1, 6, 3, 7]
        marble = list_to_marbles(marbles_list)
        current_marble = marble.next_n(5)
        next_marble_value = 11

        # act
        (score, current_marble) = play_round(current_marble, next_marble_value)

        # assert
        result = marbles_to_list(marble)
        self.assertEqual(result, [0, 8, 4, 9, 2, 10, 5, 11, 1, 6, 3, 7])
        self.assertEqual(score, 0)
        self.assertEqual(current_marble.value, 11)
Esempio n. 8
0
    def test_play_round_special_round(self):
        # arrange
        marbles_list = [
            0, 16, 8, 17, 4, 18, 9, 19, 2, 20, 10, 21, 5, 22, 11, 1, 12, 6, 13,
            3, 14, 7, 15
        ]
        marble = list_to_marbles(marbles_list)
        current_marble = marble.next_n(13)
        next_marble_value = 23

        # act
        (score, current_marble) = play_round(current_marble, next_marble_value)

        # assert
        result = marbles_to_list(marble)
        self.assertEqual(result, [
            0, 16, 8, 17, 4, 18, 19, 2, 20, 10, 21, 5, 22, 11, 1, 12, 6, 13, 3,
            14, 7, 15
        ])
        self.assertEqual(score, 32)
        self.assertEqual(current_marble.value, 19)