Exemple #1
0
    def test_winner(self):
        losing_player = StrategyPlayer('loser', 'X', [1, 4, 7])
        winning_player = StrategyPlayer('winner', 'O', [2, 5, 8])

        game = Game(losing_player, winning_player)
        game.current_player = winning_player
        winner = game.enter_game_loop()
        self.assertEqual(winner, winning_player)
Exemple #2
0
    def test_draw(self):
        player1 = StrategyPlayer('player1', 'X', [1, 3, 6, 8])
        player2 = StrategyPlayer('player2', 'O', [2, 4, 5, 7, 9])

        game = Game(player1, player2)
        game.current_player = player2
        result = game.enter_game_loop()
        self.assertEqual(result, None)
Exemple #3
0
 def test_make_invalid_move1(self):
     game = Game(self.player1, self.player2)
     gb = game.game_board
     game.current_player = self.player1
     gb.update_board(game.who_is_moving(), 2)
     game.toggle_player()
     gb.update_board(game.who_is_moving(), 2)
     self.assertFalse(gb.is_space_free(2))
Exemple #4
0
 def test_who_is_playing(self):
     game = Game(self.player1, self.player2)
     game.current_player = self.player1
     self.assertEqual(game.who_is_moving(), self.player1)