static void ProcessFromConsole(IClientCarParkService service) { while (true) { try { string input = Console.ReadLine(); if (input.Equals("exit")) { break; } var output = service.Execute(input); Console.WriteLine(output); } catch (ParkingSystemException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public void Setup() { carParkService = CarParkServiceFactory.Build(CarParkModelType.SmartModel); string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"File{Path.DirectorySeparatorChar}file_input.txt"); if (File.Exists(filePath)) { commands = File.ReadAllLines(filePath); } else { Console.WriteLine($"Unable to locate file path: {filePath}"); } filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"File{Path.DirectorySeparatorChar}file_output.txt"); if (File.Exists(filePath)) { source_results = File.ReadAllLines(filePath); } else { Console.WriteLine($"Unable to locate file path: {filePath}"); } }
public void Setup() { carParkService = CarParkServiceFactory.Build(CarParkModelType.SmartModel); string input = "create_parking_lot 6"; carParkService.Execute(input); }
public void Setup() { carParkService = CarParkServiceFactory.Build(CarParkModelType.SmartModel); string input = "create_parking_lot 10"; carParkService.Execute(input); var parkInputs = TestHelper.Generate6ParkCarInputs(); foreach (var parkInput in parkInputs) { carParkService.Execute(parkInput.Key); } }
static void ProcessFromFile(IClientCarParkService service, string fileName) { bool isExist = false; string filePath = ""; //Check if file exists if (File.Exists(fileName)) { isExist = true; filePath = fileName; } else { filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName); if (File.Exists(filePath)) { isExist = true; } } if (isExist) { string[] lines = File.ReadAllLines(filePath); try { foreach (string input in lines) { var output = service.Execute(input); Console.WriteLine(output); } } catch (ParkingSystemException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { Console.WriteLine($"Unable to locate file path: {filePath}"); Console.WriteLine("Exiting program.."); } }
static void Main(string[] args) { IClientCarParkService carParkService = CarParkServiceFactory.Build(CarParkModelType.SmartModel); int numberOfArguments = args.Length; if (numberOfArguments > 0) { // Execute commands via file ProcessFromFile(carParkService, args[0]); } else { // Execute commands via interactive console ProcessFromConsole(carParkService); } }
public void Setup() { carParkService = CarParkServiceFactory.Build(CarParkModelType.SmartModel); }