Esempio n. 1
0
        public void Whether_King_CantMoveToIncorrectSquare_On_CanMoveTo()
        {
            var board = new Board();
            var king  = new King(new Square(4, 4), board, PieceColor.White);

            Assert.That(king.CanMoveTo(new Square(6, 6)), Is.False);
        }
Esempio n. 2
0
        public void Whether_King_CantEscapeFromRookOnTheSameFile_OnCanMoveTo()
        {
            var board  = new Board();
            var king   = new King(new Square(4, 4), board, PieceColor.White);
            var bishop = new Rook(new Square(5, 4), board, PieceColor.Black);

            Assert.That(king.CanMoveTo(new Square(3, 4)), Is.False);
        }
Esempio n. 3
0
        public void Whether_King_CantMoveToBeatenPawnSquare_On_CanMoveTo()
        {
            var board  = new Board();
            var king   = new King(new Square(4, 4), board, PieceColor.White);
            var bishop = new Pawn(new Square(5, 4), board, PieceColor.Black);

            Assert.That(king.CanMoveTo(new Square(4, 3)), Is.False);
        }
Esempio n. 4
0
        public void Whether_King_CantMoveOutsideTheBoard_On_CanMoveTo()
        {
            var board = new Board();
            var king  = new King(new Square(1, 1), board, PieceColor.White);

            Assert.That(king.PossibleMoves().Count() == 3);
            Assert.That(king.CanMoveTo(new Square(-1, -1)), Is.False);
        }
Esempio n. 5
0
        public void Whether_King_CantMoveToOccupiedSquare_On_CanMoveTo()
        {
            var board         = new Board();
            var king          = new King(new Square(4, 4), board, PieceColor.White);
            var anotherKnight = new Knight(new Square(5, 5), board, PieceColor.White);

            Assert.That(king.CanMoveTo(new Square(5, 5)), Is.False);
        }
Esempio n. 6
0
        public void Whether_King_CantEscapeFromBishopOnTheSameDiagonal_OnCanMoveTo()
        {
            var board  = new Board();
            var king   = new King(new Square(4, 4), board, PieceColor.White);
            var bishop = new Bishop(new Square(5, 5), board, PieceColor.Black);

            Assert.That(king.CanMoveTo(new Square(3, 3)), Is.False);
        }
Esempio n. 7
0
        public void Whether_King_CanMoveToPossibleSquare_On_CanMoveTo(int offsetX, int offsetY)
        {
            var board = new Board();
            var king  = new King(new Square(4, 4), board, PieceColor.White);

            Assert.That(king.CanMoveTo(
                            new Square(king.Position.XPosition + offsetX,
                                       king.Position.YPosition + offsetY)));
        }
Esempio n. 8
0
        public void CanMoveTo_should_return_false_when_target_square_is_not_valid()
        {
            // Arrange
            const string currentSquare = "f1";
            const string targetSquare  = "d8";
            ChessmenBase king          = new King(Color.Black, currentSquare);

            // Act
            var result = king.CanMoveTo(targetSquare);

            // Assert
            Assert.That(result, Is.False);
        }