def test_PlayedPosition(self): # Um jogador vai jogar uma posicao... Teste se a mudansa foi feita no # tabuleiro. Repare que a valor do "player_id" nao importa. board = Board() player_id = "x" row = 2 col = 1 board.PlayPosition(row, col, player_id) self.assertTrue(board.HasPosition(row, col, player_id)) self.assertFalse(board.IsFree(row, col))
def test_EscolheParaGanharComLinha(self): board = Board() player_id = "x" computer_player = ComputerPlayer(computer_id=player_id, human_id="o") # Set pattern: # * | x | x Expect (0, 0) # ---+---+--- # | | # ---+---+--- # | | board.PlayPosition(0, 1, player_id) board.PlayPosition(0, 2, player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(0, 0, player_id)) self.assertTrue(board.PlayerWon(player_id))
def test_NaoDeixaOutroJogadorVencerComLinha(self): board = Board() player_id = "x" other_player_id = "o" computer_player = ComputerPlayer(computer_id=player_id, human_id=other_player_id) # Set pattern: # * | o | o Expect (0, 0) to be "x" # ---+---+--- # | | # ---+---+--- # | | board.PlayPosition(0, 1, other_player_id) board.PlayPosition(0, 2, other_player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(0, 0, player_id))
def test_VaiJogarParaVencerEmVezDeBloquar(self): board = Board() player_id = "x" other_player_id = "o" computer_player = ComputerPlayer(computer_id=player_id, human_id=other_player_id) # Set pattern: # | o | o Expect (2, 2) to be "x" # ---+---+--- # | | # ---+---+--- # x | x | * board.PlayPosition(0, 1, other_player_id) board.PlayPosition(0, 2, other_player_id) board.PlayPosition(2, 0, player_id) board.PlayPosition(2, 1, player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(2, 2, player_id)) self.assertTrue(board.PlayerWon(player_id))