Ejemplo n.º 1
0
        public void PieceIsThreatenedByKingReturnsFalseIfBlackKingIntersectsBlackPiece()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithNoPieces();

            var blackPawnPosition = new Position(2, 2);
            var blackKingPosition = new Position(blackPawnPosition.Row + 1, blackPawnPosition.Column + 1);

            chessboard[blackPawnPosition].Piece = new Pawn(PieceColor.Black);
            chessboard[blackKingPosition].Piece = new King(PieceColor.Black);

            var threatened = chessboard.PieceIsThreatenedByKing(blackPawnPosition);

            Assert.IsFalse(threatened);
        }
Ejemplo n.º 2
0
        public void PieceIsThreatenedByKingReturnsFalseIfWhiteKingIntersectsWhitePiece()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithNoPieces();

            var whitePawnPosition = new Position(2, 2);
            var whiteKingPosition = new Position(whitePawnPosition.Row + 1, whitePawnPosition.Column + 1);

            chessboard[whitePawnPosition].Piece = new Pawn(PieceColor.White);
            chessboard[whiteKingPosition].Piece = new King(PieceColor.White);

            var threatened = chessboard.PieceIsThreatenedByKing(whitePawnPosition);

            Assert.IsFalse(threatened);
        }
Ejemplo n.º 3
0
        public void PieceIsThreatenedByQueenReturnsTrueIfWhiteQueenIntersectsBlackPiece()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithNoPieces();

            var blackPawnPosition  = new Position(2, 2);
            var whiteQueenPosition = new Position(blackPawnPosition.Row + 2, blackPawnPosition.Column + 2);

            chessboard[blackPawnPosition].Piece  = new Pawn(PieceColor.Black);
            chessboard[whiteQueenPosition].Piece = new Queen(PieceColor.White);

            var threatened = chessboard.PieceIsThreatenedByQueen(blackPawnPosition);

            Assert.IsTrue(threatened);
        }
Ejemplo n.º 4
0
        public void PieceIsThreatenedByBishopsReturnsTrueIfBlackBishopIntersectsWhitePiece()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithNoPieces();

            var whitePawnPosition   = new Position(2, 2);
            var blackBishopPosition = new Position(whitePawnPosition.Row + 2, whitePawnPosition.Column + 2);

            chessboard[whitePawnPosition].Piece   = new Pawn(PieceColor.White);
            chessboard[blackBishopPosition].Piece = new Bishop(PieceColor.Black);

            var threatened = chessboard.PieceIsThreatenedByBishops(whitePawnPosition);

            Assert.IsTrue(threatened);
        }
Ejemplo n.º 5
0
        public static ChessboardClassic GetChessboardClassicWithNoPieces()
        {
            var chessboard = new ChessboardClassic();

            for (var row = 1; row < 9; row++)
            {
                for (var column = 1; column < 9; column++)
                {
                    chessboard[row, column].Piece = null;
                }
            }

            return(chessboard);
        }
Ejemplo n.º 6
0
 public void Setup()
 {
     chessboard = new ChessboardClassic();
 }
Ejemplo n.º 7
0
        public void IsCheckmateForProvidedColorReturnsTrueForBlackIfBlackIsInCheckmate()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorInCheckmate(PieceColor.Black);

            Assert.IsTrue(chessboard.IsCheckmateForProvidedColor(PieceColor.Black));
        }
Ejemplo n.º 8
0
        public void IsCheckmateForProvidedColorReturnsTrueForWhiteIfWhiteIsInCheckmate()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorInCheckmate(PieceColor.White);

            Assert.IsTrue(chessboard.IsCheckmateForProvidedColor(PieceColor.White));
        }