예제 #1
0
        public void EatOpponent(int sourceRow, int sourceColumn, bool isBlack, int destinationRow, int destinationColumn, bool result)
        {
            var pawn = new Pawn
            {
                Row     = 2,
                Column  = 0,
                IsBlack = !isBlack
            };

            Formation.Pieces.Add(pawn);

            var rook = new Rook
            {
                Row     = sourceRow,
                Column  = sourceColumn,
                IsBlack = isBlack
            };
            var targetField = new Field(destinationRow, destinationColumn);

            Assert.That(rook.CanMove(targetField), Is.EqualTo(result));
            Assert.That(Formation.Pieces.Contains(pawn));

            rook.TryConsumeAtTargetField(targetField);

            Assert.That(Formation.Pieces.Contains(pawn), Is.False);
            Assert.That(rook.Column, Is.EqualTo(targetField.Column));
            Assert.That(rook.Row, Is.EqualTo(targetField.Row));
        }
예제 #2
0
        public void IsMovementValid(int sourceRow, int sourceColumn, bool isBlack, int destinationRow, int destinationColumn, bool result)
        {
            var rook = new Rook
            {
                Row     = sourceRow,
                Column  = sourceColumn,
                IsBlack = isBlack
            };
            var targetField = new Field(destinationRow, destinationColumn);

            Assert.That(rook.CanMove(targetField), Is.EqualTo(result));
        }
예제 #3
0
        public void Rook_CanMove_InvalidMove_ShouldReturnFalse()
        {
            // arrange
            Models.Position.Position startingPosition    = new Models.Position.Position(0, 0);
            Models.Position.Position destinationPosition = new Models.Position.Position(1, 2);
            var rook = new Rook(startingPosition, TeamColor.Black);

            // act
            bool result = rook.CanMove(destinationPosition);

            // assert
            Assert.False(result);
        }
예제 #4
0
        public void Rook_CanMove_ValidMoveHorizontal_ShouldReturnTrue()
        {
            // arrange
            Models.Position.Position startingPosition    = new Models.Position.Position(0, 0);
            Models.Position.Position destinationPosition = new Models.Position.Position(2, 0);
            var rook = new Rook(startingPosition, TeamColor.Black);

            // act
            bool result = rook.CanMove(destinationPosition);

            // assert
            Assert.True(result);
        }
예제 #5
0
        public void IsSomethingInTheWay(int sourceRow, int sourceColumn, bool isBlack, int destinationRow, int destinationColumn, bool result)
        {
            var pawn = new Pawn
            {
                Row     = 2,
                Column  = 0,
                IsBlack = isBlack
            };

            Formation.Pieces.Add(pawn);

            var rook = new Rook
            {
                Row     = sourceRow,
                Column  = sourceColumn,
                IsBlack = isBlack
            };
            var targetField = new Field(destinationRow, destinationColumn);

            Assert.That(rook.CanMove(targetField), Is.EqualTo(result));
        }