Exemplo n.º 1
0
class BishopTests(unittest.TestCase):
    def setUp(self):
        chess_coord_white = ChessCoord('F', '8')
        self.bishop_white = Bishop(chess_coord_white, white)
        chess_coord_black = ChessCoord('E', '3')
        self.bishop_black = Bishop(chess_coord_black, black)

    def test_constructor_white(self):
        self.failUnless(self.bishop_white.letter == 'B')
        self.failUnless(self.bishop_white.chess_coord == ChessCoord('F', '8'))
        self.failUnless(self.bishop_white.grid_coord == GridCoord(5, 7))
        self.failUnless(self.bishop_white.colour == white)
        self.failUnless(self.bishop_white.symbol == '♗')
        self.failUnless(util.compare_lists(self.bishop_white.move_directions,
                                           directions.move_directions_bishop()))

    def test_constructor_black(self):
        self.failUnless(self.bishop_black.letter == 'B')
        self.failUnless(self.bishop_black.chess_coord == ChessCoord('E', '3'))
        self.failUnless(self.bishop_black.grid_coord == GridCoord(4, 2))
        self.failUnless(self.bishop_black.colour == black)
        self.failUnless(self.bishop_black.symbol == '♝')
        self.failUnless(util.compare_lists(self.bishop_black.move_directions,
                                           directions.move_directions_bishop()))

    def test_white_bishop_allowed_to_move_south3_west3(self):
        pieces = []
        self.failUnless(self.bishop_white.inspect_move(pieces,
                                                       ChessCoord('C', '5')).is_valid_move)

    def test_black_bishop_allowed_to_move_north4_west4(self):
        pieces = []
        self.failUnless(self.bishop_black.inspect_move(pieces,
                                                       ChessCoord('A', '7')).is_valid_move)
    def test_taking_king_not_allowed(self):
        d4_bishop = Bishop(ChessCoord('D', '4'), black)
        e3_king = King(ChessCoord('E', '3'), white)
        pieces = [d4_bishop, e3_king]
        move_inspect_result = d4_bishop.inspect_move(pieces, ChessCoord('E', '3'))

        self.failUnless(move_inspect_result ==
                        MoveInspectResult(False, True, [], e3_king))