/// <summary> /// Creates the rover and sets its initial position and heading /// </summary> /// <param name="initialPosition"></param> /// <returns></returns> private IRover SetUpRover(string initialPosition) { IRover rover = new Rover(); var items = initialPosition.Trim().Split(' '); rover.SetPosition(new Position { X = Convert.ToUInt64(items[0]), Y = Convert.ToUInt64(items[1]) }); switch (items[2].ToUpperInvariant()) { case "N": _roverService.SetRoverHeading(rover, Heading.North); break; case "S": _roverService.SetRoverHeading(rover, Heading.South); break; case "E": _roverService.SetRoverHeading(rover, Heading.East); break; case "W": _roverService.SetRoverHeading(rover, Heading.West); break; default: throw new MissionInputException($"Invalid input for rover initial direction: ${items[2]}"); } return(rover); }
public void SetGetRoverHeading() { // Arrange var expected = Heading.West; _service.SetRoverHeading(_rover, expected); // Act var actual = _service.GetRoverHeading(_rover); // Assert Assert.IsTrue(actual == expected); }