Пример #1
0
        public void First_Move_Sets_First_Move_Property()
        {
            _chessBoard.Add(Arg.Any <IChessPiece>(),
                            Arg.Any <int>(), Arg.Any <int>(), Arg.Any <PieceColor>()
                            ).Returns(true).AndDoes(x => _pawn.SetBoard(_chessBoard));
            _chessBoard.Add(_pawn, 1, 1, _pawn.Color);

            _chessBoard.CurrentTurn.Returns(2);
            _pawn.Move(MovementType.Move, 1, 3);
            Assert.That(_pawn.FirstMovedOn, Is.EqualTo(2));
        }
Пример #2
0
        public void Avoids_Duplicate_Positioning()
        {
            IPiece firstPawn  = ChessApi.Factory.CreatePawn(pieceColor: PieceColor.Black, chessBoard: chessBoard);
            IPiece secondPawn = ChessApi.Factory.CreatePawn(pieceColor: PieceColor.Black, chessBoard: chessBoard);

            var firstPawnOutcome  = chessBoard.Add(firstPawn, 6, 3);
            var secondPawnOutcome = chessBoard.Add(secondPawn, 6, 3);

            Assert.AreEqual(firstPawnOutcome, MethodOutcome.Success);
            Assert.AreEqual(secondPawnOutcome, MethodOutcome.Fail);
            Assert.AreEqual(firstPawn.XCoordinate, 6);
            Assert.AreEqual(firstPawn.YCoordinate, 3);
        }
Пример #3
0
        public void ChessPiece_Move_Sets_X_Coordinate_For_Valid_Move()
        {
            IChessPiece piece = CreatePiece(PieceType.Pawn, PieceColor.Black);

            _chessBoard.Add(Arg.Any <IChessPiece>(),
                            Arg.Do <int>(x => piece.XCoordinate = x),
                            Arg.Do <int>(y => piece.YCoordinate = y),
                            piece.Color).Returns(true).AndDoes(x => piece.SetBoard(_chessBoard));
            _chessBoard.IsMoveValid(Arg.Any <Move>()).Returns(true);

            _chessBoard.Add(piece, 3, 6, piece.Color);
            piece.Move(MovementType.Move, 2, 6);
            Assert.That(piece.XCoordinate, Is.EqualTo(2));
        }
Пример #4
0
 public void _31_black_pawn_capture_white_pawn()
 {
     _chessBoard.Add(_pawn, 3, 6);
     _chessBoard.Add(_opponent, 4, 1);
     Assert.That(_chessBoard.PiecesOnBoard(), Is.EqualTo(2));
     _pawn.Move(3, 5);
     _pawn.Move(3, 4);
     Assert.That(_pawn.XCoordinate, Is.EqualTo(3));
     Assert.That(_pawn.YCoordinate, Is.EqualTo(4));
     _opponent.Move(4, 3);
     Assert.That(_opponent.XCoordinate, Is.EqualTo(4));
     Assert.That(_opponent.YCoordinate, Is.EqualTo(3));
     ((Pawn)_pawn).Capture(4, 3);
     Assert.That(_pawn.XCoordinate, Is.EqualTo(4));
     Assert.That(_pawn.YCoordinate, Is.EqualTo(3));
     Assert.That(_chessBoard.PiecesOnBoard(), Is.EqualTo(1));
 }
Пример #5
0
 public void _01_placing_the_white_pawn_on_X_equals_6_and_Y_equals_1_should_place_the_white_pawn_on_that_place_on_the_board()
 {
     _chessBoard.Add(_pawn, 6, 1);
     Assert.That(_pawn.XCoordinate, Is.EqualTo(6));
     Assert.That(_pawn.YCoordinate, Is.EqualTo(1));
 }
Пример #6
0
        public void Avoids_Duplicate_Positioning()
        {
            IChessPiece firstPawn  = Substitute.For <IChessPiece>();
            IChessPiece secondPawn = Substitute.For <IChessPiece>();

            _chessBoard.Add(firstPawn, 0, 0, firstPawn.Color);
            _chessBoard.Add(secondPawn, 0, 0, secondPawn.Color);
            Assert.That(firstPawn.XCoordinate, Is.EqualTo(0));
            Assert.That(firstPawn.YCoordinate, Is.EqualTo(0));
            Assert.That(secondPawn.XCoordinate, Is.EqualTo(-1));
            Assert.That(secondPawn.YCoordinate, Is.EqualTo(-1));
        }
Пример #7
0
        public void ChessBoard_Add_Sets_XCoordinate()
        {
            var outcome = chessBoard.Add(pawnBlack, 6, 3);

            Assert.AreEqual(outcome, MethodOutcome.Success);
            Assert.AreEqual(pawnBlack.XCoordinate, 6);
        }