예제 #1
0
        public void Given_Command_Then_RoverIsDeployedToCorrectLocation(string deployCommand, int expectedMapX, int expectedMapY, int expectedStartX, int expectedStartY, string expectedOrientation)
        {
            var rover = MockRepository.GenerateStub<IRover>();
            var roverController = new RoverController(rover);

            roverController.DeployRover(deployCommand);

            rover.AssertWasCalled(r => r.Land(Arg<Map>.Matches(m => m.X == expectedMapX && m.Y == expectedMapY), Arg<int>.Is.Equal(expectedStartX), Arg<int>.Is.Equal(expectedStartY), Arg<CompassPoint>.Is.Equal(ParseCompassPoint(expectedOrientation))));
        }
예제 #2
0
        public void Given_Command_Then_RoverNavigatesToCorrectLocation(string initialPosition, string command, string finalPosition)
        {
            var rover = new Rover();
            var roverController = new RoverController(rover);

            roverController.DeployRover(initialPosition);
            roverController.CommandRover(command);

            Assert.That(roverController.ReportRoverPositionAndDirection(), Is.EqualTo(finalPosition));
        }
예제 #3
0
        public void Given_Command_Then_RoverMoveIsCalledTheCorrectAmmountOfTimes(string initialPosition, string command, int repeatMove, int repeatLeft, int repeatRight)
        {
            var rover = MockRepository.GenerateStub<IRover>();
            var roverController = new RoverController(rover);

            roverController.CommandRover(command);

            rover.AssertWasCalled(r => r.Move(), move => move.Repeat.Times(repeatMove));
            rover.AssertWasCalled(r => r.RotateLeft(), rotateLeft => rotateLeft.Repeat.Times(repeatLeft));
            rover.AssertWasCalled(r => r.RotateRight(), rotateRight => rotateRight.Repeat.Times(repeatRight));
        }