コード例 #1
0
	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
コード例 #2
0
	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
コード例 #3
0
 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))
コード例 #4
0
 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))
コード例 #5
0
	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)
コード例 #6
0
	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