Beispiel #1
0
        public void WestCommand_GetNewPoint_ShouldReturn_Null_ForInvalidPosition()
        {
            var command = new WestCommand()
            {
                Limit = 10
            };

            var data = command.GetNewPoint(0, 10);

            Assert.Null(data);
        }
Beispiel #2
0
        public void WestCommand_GetNewPoint_ShouldReturn_CorrectData_ForValidPosition()
        {
            var command = new WestCommand()
            {
                Limit = 10
            };

            var data = command.GetNewPoint(9, 5);

            Assert.NotNull(data);
            Assert.Equal(8, data.X);
            Assert.Equal(5, data.Y);
        }
Beispiel #3
0
        public void ShouldNotExecuteOutsideLimitsWhenOnNegativePosition()
        {
            var       startingPosition = new Position(-2, 0);
            const int steps            = 5;
            const int positionLimit    = 4;

            var command = new WestCommand(steps);

            var(lastPosition, positions) = command.Execute(startingPosition, positionLimit);

            var expectedLastPosition = new Position(-4, 0);
            var expectedPositions    = new List <Position>
            {
                new Position(-2, 0),
                new Position(-3, 0),
                new Position(-4, 0)
            };

            lastPosition.Should().Be(expectedLastPosition);
            positions.Should().BeEquivalentTo(expectedPositions);
        }
Beispiel #4
0
        public void ShouldExecute()
        {
            var       startingPosition = new Position(2, -3);
            const int steps            = 3;
            const int positionLimit    = 10;

            var command = new WestCommand(steps);

            var(lastPosition, positions) = command.Execute(startingPosition, positionLimit);

            var expectedLastPosition = new Position(-1, -3);
            var expectedPositions    = new List <Position>
            {
                new Position(2, -3),
                new Position(1, -3),
                new Position(0, -3),
                new Position(-1, -3)
            };

            lastPosition.Should().Be(expectedLastPosition);
            positions.Should().BeEquivalentTo(expectedPositions);
        }