static void Main(string[] args) { string API_URL = ConfigurationManager.AppSettings["API_URL"]; string AppID = ConfigurationManager.AppSettings["AppID"]; string DeveloperKey = ConfigurationManager.AppSettings["DeveloperKey"]; // validate if a parameter was provided if (args != null && args.Length > 0) { // Build url with parameters string url = $"{API_URL}/Road/{args[0]}?app_id={AppID}&app_key={DeveloperKey}"; IRoadStatusManager roadStatusManager = new RoadStatusManager(); ConsoleResponse response = roadStatusManager.RoadStatus(url); // write responses foreach (string line in response.Lines) { Console.WriteLine(line); } Environment.Exit(response.ExitCode); } else // No parameter was provided { Console.WriteLine("Provide road id as parameter"); Environment.Exit((int)EnumExitCode.ParamError); } }
public void TestRoadStatus_InvalidURL() { // Build url with parameters string url = "Invalid URL"; RoadStatusManager roadStatusManager = new RoadStatusManager(); var result = roadStatusManager.RoadStatus(url); Assert.IsNotNull(result); //Checks for null Assert.IsInstanceOfType(result, typeof(ConsoleResponse)); //Ensures type is ConsoleResponse Assert.AreEqual(2, result.ExitCode); }
public void TestRoadStatus_NonExistentRoad_A999() { string Road = "A999"; // Build url with parameters string url = $"{_API_URL}/Road/{Road}?app_id={_appID}&app_key={_developerKey}"; RoadStatusManager roadStatusManager = new RoadStatusManager(); var result = roadStatusManager.RoadStatus(url); Assert.IsNotNull(result); //Checks for null Assert.IsInstanceOfType(result, typeof(ConsoleResponse)); //Ensures type is ConsoleResponse Assert.AreEqual(1, result.ExitCode); }