static void Main(string[] args) { Rover theRover = new Rover(); var executingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var path = executingDirectory + "\\logger.txt"; ILogger theLogger = new Logger(path); RoverDecorator rover = new RoverDecorator(theRover, theLogger); Console.WriteLine("Hi, welcome to the Mars Rover!"); Command command = Command.Unknown; do { Console.WriteLine("Please enter a valid command: Move (F)orward, Move (B)ackward, Turn (L)eft, Turn (R)ight, or (Q)uit."); string input = Console.ReadLine(); command = CommandParser.ParseCommand(input); if (command == Command.Unknown) { System.Console.WriteLine("Invalid command!"); } else { rover.ProcessCommand(command); } } while (command != Command.Quit); Console.WriteLine($"Rover is at {theRover.X} , {theRover.Y} facing {theRover.Orientation}"); Process.Start("notepad.exe", path); }
static void Main(string[] args) { Console.WriteLine("Please enter a full path for logging. Press enter to use a default file."); var path = Console.ReadLine(); ILogger logger = CreateLogger(path); var roverDecorator = new RoverDecorator(new Rover(), logger); var commandConverter = new UserInputToCommandConverter(); Command command = Command.Unknown; while (command != Command.Quit) { Console.WriteLine(roverDecorator.FormatRover()); Console.WriteLine("Enter a valid command:"); Console.WriteLine("Move (F)orward, Move (B)ackward, Turn (L)eft, Turn (R)ight, (Q)uit"); var input = Console.ReadLine(); command = commandConverter.ConvertToCommand(input); if (command == Command.Unknown) { Console.WriteLine("Wasn't able to parse " + input + " as a valid command."); } else { roverDecorator.ProcessCommand(command); } } }
public void TestInitialize() { _rover = new Mock <IRover>(); _logger = new Mock <ILogger>(); _decorator = new RoverDecorator(_rover.Object, _logger.Object); }
public void Setup() { _rover = Substitute.For <IRover>(); _logger = Substitute.For <ILogger>(); _roverDecorator = new RoverDecorator(_rover, _logger); }