Beispiel #1
0
        public void LocationContainsPieceReturnsFalseForDifferentPieceTypeWithoutProvidingColor2()
        {
            var chessboard          = ChessboardProvider.GetChessboardClassicWithNoPieces();
            var blackBishopPosition = new Position(3, 3);

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

            Assert.IsFalse(Utilities.LocationContainsPiece <Rook>(chessboard[blackBishopPosition]));
        }
Beispiel #2
0
        public void LocationContainsPieceReturnsFalseForAppropriatePieceTypeAndDifferentProvidedColor1()
        {
            var chessboard        = ChessboardProvider.GetChessboardClassicWithNoPieces();
            var whitePawnPosition = new Position(1, 1);

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

            Assert.IsFalse(Utilities.LocationContainsPiece <Pawn>(chessboard[whitePawnPosition], PieceColor.Black));
        }
Beispiel #3
0
        public void LocationContainsPieceReturnsTrueForAppropriatePieceTypeWithoutProvidingColor2()
        {
            var chessboard          = ChessboardProvider.GetChessboardClassicWithNoPieces();
            var blackBishopPosition = new Position(3, 3);

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

            Assert.IsTrue(Utilities.LocationContainsPiece <Bishop>(chessboard[blackBishopPosition]));
        }
Beispiel #4
0
        public void LocationContainsPieceReturnsFalseForDifferentPieceTypeWithoutProvidingColor1()
        {
            var chessboard        = ChessboardProvider.GetChessboardClassicWithNoPieces();
            var whitePawnPosition = new Position(1, 1);

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

            Assert.IsFalse(Utilities.LocationContainsPiece <Queen>(chessboard[whitePawnPosition]));
        }
Beispiel #5
0
        public void LocationContainsPieceReturnsFalseForAppropriatePieceTypeAndDifferentProvidedColor2()
        {
            var chessboard          = ChessboardProvider.GetChessboardClassicWithNoPieces();
            var blackBishopPosition = new Position(3, 3);

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

            Assert.IsFalse(Utilities.LocationContainsPiece <Bishop>(chessboard[blackBishopPosition], PieceColor.White));
        }
        public void TestThatWhenAiPlayerIsInCheckmatePerformMoveReturnsExpectedResponse()
        {
            randomMovesAiPlayer.Turn = PieceColor.White;
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorInCheckmate(PieceColor.White);

            var aiResponse = randomMovesAiPlayer.PerformMove(chessboard);

            Assert.AreEqual(AIResponse.NoMovesLeft, aiResponse);
        }
        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);
        }
        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);
        }
        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);
        }
        public void TestThatWhenMoveIsAvailableForAiPerformMovePerformsExpectedMoveReturnsExpectedResult()
        {
            randomMovesAiPlayer.Turn = PieceColor.White;
            chessboard = ChessboardProvider.GetChessboardClassicSingleMoveAvailableForProvidedColor(PieceColor.White);

            var aiResponse = randomMovesAiPlayer.PerformMove(chessboard);

            var expectedMovePosition = new Position(8, 8);

            Assert.AreEqual(AIResponse.SuccessfulMove, aiResponse);
            Assert.IsNotNull(chessboard[expectedMovePosition].Piece);
            Assert.IsTrue(chessboard[expectedMovePosition].Piece is Pawn);
            Assert.IsTrue(chessboard[expectedMovePosition].Piece.Color == PieceColor.White);
        }
        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);
        }
        public void TestThatWhenAiPlayerCanRetakePiecePerformMoveRetakesPieceAndReturnsExpectedResponse()
        {
            randomMovesAiPlayer.Turn = PieceColor.White;
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorAboutToRetakePiece(PieceColor.White, new Rook(PieceColor.White));
            var retakenPiecesCountBeforeMove = chessboard.CapturedPieceCollection.GetEntryCount(new Rook(PieceColor.White));

            var aiResponse = randomMovesAiPlayer.PerformMove(chessboard);

            var retakenPiecesCountAfterMove = chessboard.CapturedPieceCollection.GetEntryCount(new Rook(PieceColor.White));
            var expectedRetakePosition      = new Position(8, 8);

            Assert.AreEqual(AIResponse.SuccessfulMove, aiResponse);
            Assert.IsNotNull(chessboard[expectedRetakePosition].Piece);
            Assert.IsTrue(chessboard[expectedRetakePosition].Piece is Rook);
            Assert.IsTrue(chessboard[expectedRetakePosition].Piece.Color == PieceColor.White);
            Assert.AreEqual(retakenPiecesCountAfterMove, retakenPiecesCountBeforeMove - 1);
        }
Beispiel #13
0
 public void Setup()
 {
     chessboard = ChessboardProvider.GetChessboardClassicFilledWithPawns(PieceColor.Black);
 }
        public void IsCheckmateForProvidedColorReturnsTrueForBlackIfBlackIsInCheckmate()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorInCheckmate(PieceColor.Black);

            Assert.IsTrue(chessboard.IsCheckmateForProvidedColor(PieceColor.Black));
        }
        public void IsCheckmateForProvidedColorReturnsTrueForWhiteIfWhiteIsInCheckmate()
        {
            chessboard = ChessboardProvider.GetChessboardClassicWithProvidedColorInCheckmate(PieceColor.White);

            Assert.IsTrue(chessboard.IsCheckmateForProvidedColor(PieceColor.White));
        }
Beispiel #16
0
 public void Setup()
 {
     chessboard = ChessboardProvider.GetChessboardClassicWithNoPieces();
 }
Beispiel #17
0
 private void InitializeChessboard(ChessboardType chessboardType)
 {
     chessboard = ChessboardProvider.GetChessboard(chessboardType);
 }