Exemplo n.º 1
0
 def test_check_for_win_horizontal(self):
     a = Game(3, 3, 3, "x")
     a.initialize_game()
     a._place_piece(2, "P")
     a._place_piece(1, "P")
     a._place_piece(0, "P")
     self.assertEqual(a._check_for_win("P"), True)
Exemplo n.º 2
0
 def test_check_for_win_left_diagonal(self):
     a = Game(3, 3, 3, "x")
     a.initialize_game()
     a._place_piece(0, "O")
     a._place_piece(1, "X")
     a._place_piece(1, "O")
     a._place_piece(2, "X")
     a._place_piece(2, "O")
     a._place_piece(1, "X")
     a._place_piece(2, "O")
     self.assertEqual(a._check_for_win("O"), True)
Exemplo n.º 3
0
    def test_place_piece(self):
        capture = PrintCapturer()
        with patch('ConnectNGame.src.game.print', side_effect=capture):
            a = Game(3, 3, 3, "x")
            a.initialize_game()
            a._place_piece(2, "P")
            a._place_piece(2, "P")
            board_output = "  0 1 2\n" \
                           "0 x x x\n" \
                           "1 x x x\n" \
                           "2 x x x\n" \
                           "  0 1 2\n" \
                           "0 x x x\n" \
                           "1 x x x\n" \
                           "2 x x P\n" \
                           "  0 1 2\n" \
                           "0 x x x\n" \
                           "1 x x P\n" \
                           "2 x x P\n"

            self.assertEqual(board_output, capture.as_string())