public void Prevent_White_Pawn_Movement_Backwards()
        {
            var board = SetupBoard();
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.White);
            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 1, 0, 0);

            Assert.That(rule.IsMoveValid(board, move), Is.False);
        }
        public void Prevent_Black_Pawn_Advancement_To_Occupied_Square()
        {
            var board = SetupBoard(5, PieceColor.White);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 6, 0, 5);

            Assert.That(rule.IsMoveValid(board, move), Is.False);
        }
        public void Prevent_Black_Advancement_By_Greater_Than_One_Square_When_Off_Home_Rank()
        {
            var board = SetupBoard();
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 5, 0, 3);

            Assert.That(rule.IsMoveValid(board, move), Is.False);
        }
        public void Prevent_Black_Pawn_Horizontal_Movement_Without_Capture()
        {
            var board = SetupBoard();
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 6, 1, 6);

            Assert.That(rule.IsMoveValid(board, move), Is.False);
        }
        public void Prevent_Black_Double_Step_From_Home_Rank_To_Occupied_Square()
        {
            var board = SetupBoard(4, PieceColor.White);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 6, 0, 4);

            Assert.That(rule.IsMoveValid(board, move), Is.False);
        }
        public void Allow_White_Double_Step_From_Home_Rank_To_Unoccupied_Square()
        {
            var board = SetupBoard();
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.White);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 1, 0, 3);

            Assert.That(rule.IsMoveValid(board, move), Is.True);
        }
        public void Allow_Black_Pawn_Advancement_To_Unoccupied_Square()
        {
            var board = SetupBoard();
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move move = new Move(piece, 0, 7, 0, 6);

            Assert.That(rule.IsMoveValid(board, move), Is.True);
        }
        public void Prevent_Black_Capture_On_Double_Step()
        {
            var board = SetupBoard(4, PieceColor.White);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move leftCapture = new Move(piece, 1, 6, 0, 4);

            Assert.That(rule.IsMoveValid(board, leftCapture), Is.False);
            Move rightCapture = new Move(piece, 1, 6, 2, 4);

            Assert.That(rule.IsMoveValid(board, rightCapture), Is.False);
        }
        public void Allow_Black_En_Passant()
        {
            var board = SetupBoard(3, PieceColor.White, 2);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move leftCapture = new Move(piece, 1, 3, 0, 2);

            Assert.That(rule.IsMoveValid(board, leftCapture), Is.True);
            Move rightCapture = new Move(piece, 1, 3, 2, 2);

            Assert.That(rule.IsMoveValid(board, rightCapture), Is.True);
        }
        public void Prevent_Black_Capture_Movement_On_Unoccupied_Square_Without_En_Passant()
        {
            var board = SetupBoard(3, PieceColor.White);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move leftCapture = new Move(piece, 1, 3, 0, 2);

            Assert.That(rule.IsMoveValid(board, leftCapture), Is.False);
            Move rightCapture = new Move(piece, 1, 3, 3, 2);

            Assert.That(rule.IsMoveValid(board, rightCapture), Is.False);
        }
        public void Allow_Black_Capture_Movement_On_White_Occupied_Square()
        {
            var board = SetupBoard(6, PieceColor.White);
            var piece = Substitute.For <IChessPiece>();

            piece.Color.Returns(PieceColor.Black);

            IRule rule = new ValidPawnMoveRule();

            Move leftCapture = new Move(piece, 1, 7, 0, 6);

            Assert.That(rule.IsMoveValid(board, leftCapture), Is.True);
            Move rightCapture = new Move(piece, 1, 7, 2, 6);

            Assert.That(rule.IsMoveValid(board, rightCapture), Is.True);
        }