public void ParseLanding_ShouldParseValidCoordinates(string input, int id, int x, int y, char heading) { var parser = new RoverParser(); var headingConverter = new HeadingConverter(); var results = parser.ParseLanding(input); Assert.NotNull(results); Assert.NotNull(results.Position); Assert.Equal(id, results.Id); Assert.Equal(x, results.Position.X); Assert.Equal(y, results.Position.Z); Assert.Equal(heading, headingConverter.ToChar(results.Heading)); }
public static void Main(string[] args) { var roverService = new RoverService(new RoverParser(), new RoverManager()); string fileName = args.FirstOrDefault(); var fileContents = File.ReadAllLines(fileName); if (string.IsNullOrWhiteSpace(fileName)) { System.Console.Error.WriteLine("Please enter a file name."); } else { try { roverService.ExecuteInstructions(fileContents); var headingConverter = new HeadingConverter(); foreach (var rover in roverService.EnumerateRovers()) { System.Console.WriteLine(string.Format("Rover{0}:{1} {2} {3}", rover.Id, rover.Position.X, rover.Position.Z, headingConverter.ToChar(rover.Heading))); } } catch (Exception ex) { System.Console.Error.WriteLine(ex.Message); } } System.Console.Write("Please press any key..."); System.Console.ReadLine(); }