예제 #1
0
 def test_place_knight_on_board_and_move_it(self):
     new_board = ChessBoard(3, 3)
     knight = Knight(new_board, 0, 0)
     self.assertEqual(Knight.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:0', knight.position)
     knight.move_to(0, 2)
     self.assertEqual(Knight.symbol, new_board[0, 2])
     self.assertNotEqual(Knight.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:2', knight.position)
예제 #2
0
 def test_place_bishop_on_board_and_move_it(self):
     new_board = ChessBoard(3, 3)
     bishop = Bishop(new_board, 0, 0)
     self.assertEqual(Bishop.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:0', bishop.position)
     bishop.move_to(0, 2)
     self.assertEqual(Bishop.symbol, new_board[0, 2])
     self.assertNotEqual(Bishop.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:2', bishop.position)
예제 #3
0
 def test_place_queen_on_board_and_move_it(self):
     new_board = ChessBoard(3, 3)
     queen = Queen(new_board, 0, 0)
     self.assertEqual(Queen.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:0', queen.position)
     queen.move_to(0, 2)
     self.assertEqual(Queen.symbol, new_board[0, 2])
     self.assertNotEqual(Queen.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:2', queen.position)
예제 #4
0
 def test_place_rook_on_board_and_move_it(self):
     new_board = ChessBoard(3, 3)
     rook = Rook(new_board, 0, 0)
     self.assertEqual(Rook.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:0', rook.position)
     rook.move_to(0, 2)
     self.assertEqual(Rook.symbol, new_board[0, 2])
     self.assertNotEqual(Rook.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:2', rook.position)
예제 #5
0
 def test_place_king_on_board_and_move_it(self):
     new_board = ChessBoard(3, 3)
     king = King(new_board, 0, 0)
     self.assertEqual(King.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:0', king.position)
     king.move_to(0, 2)
     self.assertEqual(King.symbol, new_board[0, 2])
     self.assertNotEqual(King.symbol, new_board[0, 0])
     self.assertEqual('X:0, Y:2', king.position)
예제 #6
0
 def test_initialize_3_by_3_chess_board(self):
     new_board = ChessBoard(3, 3)
     expected_board = '\n'.join(['|'.join(['X' for _ in range(3)]) for _ in range(3)])
     self.assertEqual(expected_board, repr(new_board))
예제 #7
0
 def test_initialize_empty_chess_board(self):
     new_board = ChessBoard(0, 0)
     expected_board = ''''''
     self.assertEqual(expected_board, repr(new_board))