Ejemplo n.º 1
0
    def test_is_won_in_diagonals_from_left_to_right_diagonal(self):
        game = Game(None, None)
        game.board.clean_marks()
        self.assertFalse(game.is_won())

        game.board.mark_cell(1, 1)
        game.board.mark_cell(5, 1)
        game.board.mark_cell(9, 1)
        self.assertTrue(game.is_won())
Ejemplo n.º 2
0
    def test_is_won_in_columns(self):
        game = Game(None, None)
        game.board.clean_marks()
        self.assertFalse(game.is_won())

        game.board.mark_cell(3, 1)
        game.board.mark_cell(6, 1)
        game.board.mark_cell(9, 1)
        self.assertTrue(game.is_won())
Ejemplo n.º 3
0
 def test_ask_cells_for_tied_game(self):
     selected_cells = [1, 5, 9, 2, 8, 7, 3, 6, 4]
     game = Game(lambda _: selected_cells.pop(), self.print_function)
     game.board.clean_marks()
     game.ask_cells()
     self.assertFalse(game.is_won())
     expected_printed_messages = ' The game is over and this is a tie!!'
     messages = self.returned_string.split('\n')
     win_message = messages[len(messages) - 2]
     self.assertEqual(win_message, expected_printed_messages)
Ejemplo n.º 4
0
    def test_ask_cells_for_won_game(self):
        game = Game(lambda n: 3, self.print_function)
        game.board.clean_marks()
        game.board.mark_cell(1, 1)
        game.board.mark_cell(2, 1)

        game.ask_cells()
        self.assertTrue(game.is_won())
        expected_printed_messages = ' Player 1 wins the game!!'
        messages = self.returned_string.split('\n')
        win_message = messages[len(messages) - 2]
        self.assertEqual(win_message, expected_printed_messages)
Ejemplo n.º 5
0
 def test_start_game_for_play_option(self):
     selected_options = [2, 6, 2, 3, 7, 9, 5, 1, 1]
     game = Game(lambda _: selected_options.pop(), self.print_function)
     game.start()
     self.assertTrue(game.is_won())
Ejemplo n.º 6
0
 def test_start_game_for_exit_option(self):
     game = Game(lambda _: 2, self.print_function)
     game.start()
     self.assertFalse(game.is_won())