Ejemplo n.º 1
0
        public void Equals_TwoOppositeColorPawns_AreNotEqual()
        {
            Pawn pawn1 = new Pawn(new Board(), PieceColor.White);
            Pawn pawn2 = new Pawn(new Board(), PieceColor.Black);

            Assert.AreNotEqual(pawn1, pawn2);
        }
Ejemplo n.º 2
0
        public override ChessPiece Clone(Board board)
        {
            var clone = new Pawn(board, Color)
                {
                    MovingStrategy = MovingStrategy.Clone(board)
                };

            return clone;
        }
Ejemplo n.º 3
0
        public void Equals_TwoSameColorPawns_AreEqual()
        {
            Pawn pawn1 = new Pawn(new Board(), PieceColor.White);
            Pawn pawn2 = new Pawn(new Board(), PieceColor.White);
            Pawn pawn3 = new Pawn(new Board(), PieceColor.Black);
            Pawn pawn4 = new Pawn(new Board(), PieceColor.Black);

            Assert.AreEqual(pawn1, pawn2);
            Assert.AreEqual(pawn3, pawn4);
        }
Ejemplo n.º 4
0
        public void Setup_WhenBoardIsSetup_PositionsAlongSeventhRankReturnBlackPawns()
        {
            var expected = new Pawn(Board, PieceColor.Black);

            Board.Setup();

            Assert.AreEqual(expected, GetSquare(1, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(2, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(3, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(4, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(5, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(6, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(7, 7).Occupier);
            Assert.AreEqual(expected, GetSquare(8, 7).Occupier);
        }
Ejemplo n.º 5
0
        public void Setup_WhenBoardIsSetup_PositionsAlongSecondRankReturnWhitePawns()
        {
            var expected = new Pawn(Board, PieceColor.White);

            Board.Setup();

            Assert.AreEqual(expected, GetSquare(1, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(2, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(3, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(4, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(5, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(6, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(7, 2).Occupier);
            Assert.AreEqual(expected, GetSquare(8, 2).Occupier);
        }
Ejemplo n.º 6
0
        public void Move_WhiteMakesAnEnPassantMove_OriginalPositionIsEmptyAndTargetPositionReturnsTheChessPieceAsOccupier()
        {
            Board.Setup();
            Pawn expected = new Pawn(Board, PieceColor.White);

            Board.Move(GetSquare(4, 2), GetSquare(4, 4));
            Board.Move(GetSquare(4, 4), GetSquare(4, 5));
            Board.Move(GetSquare(3, 7), GetSquare(3, 5));
            Board.Move(GetSquare(4, 5), GetSquare(3, 6));
            var actual = GetSquare(3, 6).Occupier;

            Assert.AreEqual(new NullPiece(Board), GetSquare(4, 5).Occupier);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
 private bool Equals(Pawn other)
 {
     return !ReferenceEquals(null, other) && Color == other.Color;
 }