Example #1
0
 def test_isCatsGame_CaseFalse_WinnerExists(self):
     win = WinLogic()
     player1 = "Player1"
     player2 = "Player2"
     win.SetPlayer(player1)
     win.ClearMatrix()
     win.SetGrid(player1, 0, 0)
     win.SetGrid(player1, 1, 1)
     win.SetGrid(player1, 2, 2)
     win.SetGrid(player1, 2, 1)
     win.SetGrid(player2, 0, 1)
     win.SetGrid(player2, 0, 2)
     win.SetGrid(player2, 1, 0)
     win.SetGrid(player2, 1, 2)
     win.SetGrid(player2, 2, 0)
     self.assertFalse(win.isCatsGame(player1, player2))
	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_ClearMatrix_GetGrid_SetGrid(self):
		win = WinLogic()
		self.assertEqual(win.GetGrid(0,0),False)
		win.SetGrid("TEST",0,0)
		self.assertEqual(win.GetGrid(0,0),"TEST")
		win.ClearMatrix()
		self.assertEqual(win.GetGrid(0,0),False)
	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_hasPlayerWon_LoseCaseTwo(self): #no winner
		#Make Class
		win = WinLogic()
		player = "Player1"
		win.SetPlayer(player)
		win.ClearMatrix()
		for i in range(2):
			win.SetGrid(player,0,i)
		win.SetGrid("Player2",0,2)
		self.assertFalse(win.hasPlayerWon(player)) #lose case 2
	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