public void GivenValidActionsShouldGuideRover(int roverX, int roverY, Heading roverHeading, int expectedX, int expectedY, Heading expectedHeading, params NavigationAction[] navigationActions) { var plateau = new Plateau(new Point(5, 5)); var rover = new Rover(new Point(roverX, roverY), roverHeading); var navigationEngine = new NavigationEngine(plateau, rover); navigationEngine.Guide(rover, navigationActions); Assert.That(rover.CurrentCoordinates.X, Is.EqualTo(expectedX)); Assert.That(rover.CurrentCoordinates.Y, Is.EqualTo(expectedY)); Assert.That(rover.CurrentHeading, Is.EqualTo(expectedHeading)); }
public void GivenNavigationActionWouldMoveRoverShouldAddActionToCache() { var plateau = new Plateau(new Point(7, 7)); var initialX = 5; var initialY = 4; var initialHeading = Heading.East; var rover = new Rover(new Point(initialX, initialY), initialHeading); var navigationEngine = new NavigationEngine(plateau, rover); navigationEngine.Guide(rover, NavigationAction.M); Assert.That(navigationEngine.RoverActionsCache[rover], Is.Not.Empty); }
public void GivenNavigationActionWouldRemoveRoverFromPlateauShouldNotAddActionToCache() { var plateau = new Plateau(new Point(5, 5)); var initialX = 5; var initialY = 4; var initialHeading = Heading.East; var rover = new Rover(new Point(initialX, initialY), initialHeading); var navigationEngine = new NavigationEngine(plateau, rover); try { navigationEngine.Guide(rover, NavigationAction.M); } catch (InvalidOperationException) { // Do nothing } Assert.That(navigationEngine.RoverActionsCache[rover], Is.Empty); }
public void GivenNavigationActionWouldRemoveRoverFromPlateauShouldResetRoversPosition() { var plateau = new Plateau(new Point(5, 5)); var initialX = 5; var initialY = 4; var initialHeading = Heading.East; var rover = new Rover(new Point(initialX, initialY), initialHeading); var navigationEngine = new NavigationEngine(plateau, rover); try { navigationEngine.Guide(rover, NavigationAction.M); } catch (InvalidOperationException) { // Do nothing } Assert.That(rover.CurrentCoordinates.X, Is.EqualTo(initialX)); Assert.That(rover.CurrentCoordinates.Y, Is.EqualTo(initialY)); Assert.That(rover.CurrentHeading, Is.EqualTo(initialHeading)); }