def test_SetPlayer_GetPlayer(self): win = WinLogic() self.assertEqual(win.GetPlayer(),"") win.SetPlayer("PlayerOne") self.assertEqual(win.GetPlayer(),"PlayerOne") win.SetPlayer("PlayerTwo") self.assertEqual(win.GetPlayer(),"PlayerTwo")
def test_hasPlayerWon_RowTwo(self): #no winner #Make Class win = WinLogic() player = "Player1" win.SetPlayer(player) win.ClearMatrix() for i in range(3): win.SetGrid(player,i,1) self.assertTrue(win.hasPlayerWon(player)) #win case 5
def test_hasPlayerWon_LoseCaseOne(self): #no winner #Make Class win = WinLogic() player = "Player1" win.SetPlayer(player) win.ClearMatrix() for i in range(2): win.SetGrid(player,0,i) self.assertFalse(win.hasPlayerWon(player)) #lose case 1
def test_hasPlayerWon_DiagOne(self): #no winner #Make Class win = WinLogic() player = "Player1" win.SetPlayer(player) win.ClearMatrix() win.SetGrid(player,0,0) win.SetGrid(player,1,1) win.SetGrid(player,2,2) self.assertTrue(win.hasPlayerWon(player)) #win case 7
def test_isCatsGame_CaseFalse_BoardNotFull(self): win = WinLogic() player1 = "Player1" player2 = "Player2" win.SetPlayer(player1) win.ClearMatrix() win.SetGrid(player1, 2, 0) win.SetGrid(player1, 2, 2) win.SetGrid(player2, 0, 0) win.SetGrid(player2, 1, 1) win.SetGrid(player2, 1, 2) win.SetGrid(player2, 2, 1) self.assertFalse(win.isCatsGame(player1, player2))
def test_isCatsGame_CaseTrue(self): win = WinLogic() player1 = "Player1" player2 = "Player2" win.SetPlayer(player1) win.ClearMatrix() win.SetGrid(player1, 0, 1) win.SetGrid(player1, 0, 2) win.SetGrid(player1, 1, 0) win.SetGrid(player1, 2, 0) win.SetGrid(player1, 2, 2) win.SetGrid(player2, 0, 0) win.SetGrid(player2, 1, 1) win.SetGrid(player2, 1, 2) win.SetGrid(player2, 2, 1) self.assertTrue(win.isCatsGame(player1, player2))