public void EatOpponent(int sourceRow, int sourceColumn, bool isBlack, int destinationRow, int destinationColumn, bool result)
        {
            //Arrange
            var pawn = new Pawn
            {
                Row     = destinationRow,
                Column  = destinationColumn,
                IsBlack = !isBlack
            };

            Formation.Pieces.Add(pawn);

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

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

            //act
            queen.TryConsumeAtTargetField(targetField);


            //assert
            Assert.That(Formation.Pieces.Contains(pawn), Is.False);
            Assert.That(queen.Column, Is.EqualTo(targetField.Column));
            Assert.That(queen.Row, Is.EqualTo(targetField.Row));
        }
Esempio n. 2
0
        public void Queen_CanMove_DiagonalMove_ShouldReturnTrue()
        {
            // arrange
            Models.Position.Position startingPosition     = new Models.Position.Position(0, 0);
            Models.Position.Position destinationPosition1 = new Models.Position.Position(3, 3);
            Models.Position.Position destinationPosition2 = new Models.Position.Position(-2, 2);
            var queen = new Queen(startingPosition, TeamColor.Black);

            // act
            bool result1 = queen.CanMove(destinationPosition1);
            bool result2 = queen.CanMove(destinationPosition2);

            // assert
            Assert.True(result1);
            Assert.True(result2);
        }
        public void IsMovementValid(int sourceRow, int sourceColumn, bool isBlack, int destinationRow, int destinationColumn, bool result)
        {
            var queen = new Queen
            {
                Row     = sourceRow,
                Column  = sourceColumn,
                IsBlack = isBlack
            };
            var targetField = new Field(destinationRow, destinationColumn);

            Assert.That(queen.CanMove(targetField), Is.EqualTo(result));
        }
Esempio n. 4
0
        public void Queen_CanMove_ThisSamePosition_ShouldReturnFalse()
        {
            // arrange
            Models.Position.Position startingPosition    = new Models.Position.Position(0, 0);
            Models.Position.Position destinationPosition = new Models.Position.Position(0, 0);
            var queen = new Queen(startingPosition, TeamColor.Black);

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

            // assert
            Assert.False(result);
        }