Esempio n. 1
0
    def test_winner_by_col(self):
        """Player1 should win wen complete a col"""
        self.board = ttt.make_move('0,0', self.board, self.p1)
        self.board = ttt.make_move('1,0', self.board, self.p1)
        self.board = ttt.make_move('2,0', self.board, self.p1)

        ttt.print_board(self.board)
        self.assertEqual(ttt.status(self.board, [self.p1, self.p2]), '#')
Esempio n. 2
0
    def test_winner_by_2nd_diagonal(self):
        """Player1 should win wen complete the 2nd diagonal"""
        self.board = ttt.make_move('0,2', self.board, self.p1)
        self.board = ttt.make_move('1,1', self.board, self.p1)
        self.board = ttt.make_move('2,0', self.board, self.p1)

        ttt.print_board(self.board)
        self.assertEqual(ttt.status(self.board, [self.p1, self.p2]), '#')
Esempio n. 3
0
    def test_status_tie_game(self):
        """Should be no winner in a tie game"""

        #player1 moves
        self.board = ttt.make_move('0,0', self.board, self.p1)
        self.board = ttt.make_move('0,2', self.board, self.p1)
        self.board = ttt.make_move('1,1', self.board, self.p1)
        self.board = ttt.make_move('1,2', self.board, self.p1)
        self.board = ttt.make_move('2,1', self.board, self.p1)

        #player2 moves
        self.board = ttt.make_move('0,1', self.board, self.p2)
        self.board = ttt.make_move('1,0', self.board, self.p2)
        self.board = ttt.make_move('2,0', self.board, self.p2)
        self.board = ttt.make_move('2,2', self.board, self.p2)

        ttt.print_board(self.board)
        self.assertFalse(ttt.status(self.board, [self.p1, self.p2]))