Exemple #1
0
        public void BeFalseWhenAnyCommandIsOutBounds()
        {
            RoverController controller = new RoverController(new Size(2, 2), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.A, Commands.A, Commands.A };

            Assert.False(controller.Handle(commands));
        }
Exemple #2
0
        public void BeTrueWhenAllCommandsIsInBounds()
        {
            RoverController controller = new RoverController(new Size(10, 10), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.A, Commands.A, Commands.A };

            Assert.True(controller.Handle(commands));
        }
Exemple #3
0
        public void IncreaseYWhenAdvanceToNorth()
        {
            RoverController controller = new RoverController(new Size(2, 2), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.A };

            controller.Handle(commands);

            Assert.Equal(new Coordinates(0, 1), controller.CurrentCoordinates);
        }
Exemple #4
0
        public void RotateLeftFromWestToSouthOnLCommand()
        {
            RoverController controller = new RoverController(new Size(10, 10), new Coordinates(0, 0), CardinalPoint.West);

            Commands[] commands = new[] { Commands.L };

            controller.Handle(commands);

            Assert.Equal(CardinalPoint.South, controller.CurrentCardinalPoint);
        }
Exemple #5
0
        public void RotateRightFromNorthToEastOnRCommand()
        {
            RoverController controller = new RoverController(new Size(10, 10), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.R };

            controller.Handle(commands);

            Assert.Equal(CardinalPoint.East, controller.CurrentCardinalPoint);
        }
Exemple #6
0
        public void NotMoveToTheNextPositionWhenACommandIsOutOfBounds()
        {
            RoverController controller = new RoverController(new Size(2, 2), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.A, Commands.A, Commands.L, Commands.A, Commands.A };

            controller.Handle(commands);

            Assert.Equal(new Coordinates(0, 2), controller.CurrentCoordinates);
        }
Exemple #7
0
        public void MoveToTheNextPositionWithinBounds()
        {
            RoverController controller = new RoverController(new Size(10, 10), new Coordinates(0, 0), CardinalPoint.North);

            Commands[] commands = new[] { Commands.A, Commands.A, Commands.A };

            controller.Handle(commands);

            Assert.Equal(new Coordinates(0, 3), controller.CurrentCoordinates);
        }
Exemple #8
0
        public void DecreaseXWhenAdvanceToWest()
        {
            RoverController controller = new RoverController(new Size(2, 2), new Coordinates(1, 0), CardinalPoint.West);

            Commands[] commands = new[] { Commands.A };

            controller.Handle(commands);

            Assert.Equal(new Coordinates(0, 0), controller.CurrentCoordinates);
        }