public void MoveTo_PassValidLocation_ShouldBeSuccess(DirectionType directionType) { var coordinate = new Coordinate(3, 1); _rover.SetCoordinate(coordinate); _rover.SetDirection(directionType); _rover.MoveForward(directionType); var result = _rover.GetCurrentPosition(); result.Should().NotBeNullOrEmpty(); result.Should().Be($"{_rover.GetCoordinate().X } {_rover.GetCoordinate().Y} {directionType}"); }
public void MoveForwardFacingNorth() { // Arrange _rover.SetHeading(Heading.North); // Act var x = _rover.GetPosition().X; var y = _rover.GetPosition().Y; _rover.MoveForward(); // Assert Assert.IsTrue(_rover.GetPosition().X == x && _rover.GetPosition().Y == y + 1); }
public void RoverShouldMoveYForward(string landingArea, string position) { //Arrange _rover.Position = _helper.ToRover(position); _rover.LandingArea = _helper.ToPlateau(landingArea); //Act _rover.MoveForward(); //Assert Assert.IsNotNull(_rover); Assert.IsNotNull(_rover.Position); Assert.IsNotNull(_rover.LandingArea); Assert.AreEqual(_rover.Position.Y, 3); }
public void ProcessCommand(Command command) { switch (command) { case Command.MoveForward: _rover.MoveForward(); _logger.Log("Rover moved forward."); _logger.Log(FormatRover()); break; case Command.MoveBackward: _rover.MoveBackward(); _logger.Log("Rover moved backward."); _logger.Log(FormatRover()); break; case Command.TurnLeft: _rover.TurnLeft(); _logger.Log("Rover turned left."); _logger.Log(FormatRover()); break; case Command.TurnRight: _rover.TurnRight(); _logger.Log("Rover turned right."); _logger.Log(FormatRover()); break; case Command.Quit: _logger.Log("Rover stopped."); _logger.Log(FormatRover()); break; } }
public void Move(IRover rover) { var commands = rover.Commands.ToCharArray(); foreach (var command in commands) { switch (command) { case 'L': rover.TurnLeft(); break; case 'R': rover.TurnRight(); break; case 'M': if (CheckBoundaries(rover)) { rover.MoveForward(); } break; default: throw new CommandException(); } } }
public void Rover_MoveForward() { _rover.MoveForward(); Assert.AreEqual(1, _rover.PositionX); Assert.AreEqual(Directions.W, _rover.Direction); }
public void ProcessCommands(String commands) { foreach (var command in commands) { if (command == Forward) { rover.MoveForward(); } else if (command == Backward) { rover.MoveBackward(); } else if (command == Left) { rover.TurnLeft(); } else if (command == Right) { rover.TurnRight(); } if (rover.IsObstructed) { break; } } }
public void Execute(string commands, IRover rover) { foreach (var command in commands) { if (command == 'M') rover.MoveForward(); else if (command == 'L') rover.RotateLeft(); else rover.RotateRight(); } }
public void Execute(string commands, IRover rover) { foreach (var command in commands) { if (command == 'M') { rover.MoveForward(); } else if (command == 'L') { rover.RotateLeft(); } else { rover.RotateRight(); } } }
public void RunStep() { var command = inputSource.ReadLine(); switch (command) { case "L": rover.TurnLeft(); break; case "R": rover.TurnRight(); break; case "F": rover.MoveForward(); break; default: throw new Exception("invalid command"); } outputTarget.WriteLine($"Rover is now at ({rover.Position.X},{rover.Position.Y}) - facing {rover.Facing}"); }
private void HandleCharacter(char ch) { switch (ch) { case 'F': rover.MoveForward(); break;; case 'B': rover.MoveBackward(); break; case 'R': rover.TurnRight(); break; case 'L': rover.TurnLeft(); break; default: throw new InvalidEnumArgumentException(string.Format("The received command : '%0' is not supported", ch)); } }
public void Execute(IRover rover) { rover.MoveForward(); }
public void MoveRoverForward(IRover rover) { rover.MoveForward(); }
public void RoverMovesForwardCorrectly() { _defaultRover.MoveForward(); Assert.AreEqual(new[] { 0, 1 }, _defaultRover.GetCoords()); }
public ICmdResult Execute() { return(rover.MoveForward()); }
public void ExecuteCommand(IRover rover) { rover.MoveForward(); }