public void GivenRotateRightCommand_WhenExecute_ThenRoverTurnedRight() { IControlCommand command = new RotateRightCommand(); var rover = new Rover(plateau, "1 2 N"); command.Execute(rover); Assert.Equal(1, rover.CurrentPosition.X); Assert.Equal(2, rover.CurrentPosition.Y); Assert.Equal("E", rover.CurrentPosition.Direction); }
public void Rover_FacingNorth_AtPosition34_5x5Grid_TurnsEast() { Coordinates startPosition = new Coordinates(3, 4); IDirection currentDirection = new North(); Grid grid = new Grid(new Coordinates(0, 0), new Coordinates(5, 5)); IRover rover = new MarsRover(currentDirection, startPosition, grid); ICommand moveCommand = new RotateRightCommand(); moveCommand.Execute(rover); Assert.That(rover.CurrentDirection, Is.TypeOf <East>()); Assert.That(rover.CurrentPosition.XCoordinate == 3); Assert.That(rover.CurrentPosition.YCoordinate == 4); }
public void Execute_RobotGiven_ShouldCallRobotRotateRightMethod() { // Arrange var robotMock = new Mock <IRobot>(); var rotateRightCommand = new RotateRightCommand(); // Act rotateRightCommand.Execute(robotMock.Object); // Assert robotMock.Verify(robot => robot.RotateRight(), Times.Once()); }
public void RotateRightCommand_Should_Call_Create_Method_When_Expected_Value(Direction direction) { //Arrange var marsRoverService = new Mock <IMarsRoverService>(); var directionManagerStrategy = new Mock <IDirectionManagerStrategy>(); marsRoverService.Setup(s => s.GetCurrentRover()).Returns(new RoverPositionModel(1, 1, direction)); var moveForwardCommand = new RotateRightCommand(marsRoverService.Object, directionManagerStrategy.Object); //Act moveForwardCommand.Execute(); //Assert directionManagerStrategy.Verify(mock => mock.RotateRight(direction), Times.Once); }
public void RotateToNextOrientationOnLCommand(Orientation testOrientation, Orientation expectedOrientation) { const int dummyX = 1; const int dummyY = 1; var testPosition = new Position(dummyX, dummyY, testOrientation); const int testGridSizeX = 3; const int testGridSizeY = 3; var testTrackingModule = new TrackingModule { GridMaximumX = testGridSizeX, GridMaximumY = testGridSizeY, Position = testPosition }; var spyCommand = new SpyCommand(); var rotateCommand = new RotateRightCommand(spyCommand); rotateCommand.Execute(testTrackingModule); var actualTrackingModule = spyCommand.TrackingModule; actualTrackingModule.Position.Orientation.Should().Be(expectedOrientation); }