//test to validate positive test considering file is at the location public void GetWeatherDataTestPositive() { WeatherServiceController WSController = new WeatherServiceController(); string result = WSController.GetWeatherData("citylist.csv").Result; Assert.AreEqual("File Processed!", result); }
///catching filevalidation exception when invalid file is passed public void GetWeatherDataTestFileEmptyException() { try { WeatherServiceController WSController = new WeatherServiceController(); string result = WSController.GetWeatherData("citylist - Copy.csv").Result; } catch (Exception ex) { Assert.AreEqual(typeof(InvalidDataException), ex.InnerException.GetType()); } }
///catching filevalidation exception when invalid file is passed public void GetWeatherDataTestfilevalidationException() { try { WeatherServiceController WSController = new WeatherServiceController(); string result = WSController.GetWeatherData("myapp - Copy.csv").Result; } catch (Exception ex) { Assert.AreEqual(typeof(CsvHelper.CsvHelperException), ex.InnerException.GetType()); } }
///catching filenotfound exception when file is not there public void GetWeatherDataTestFileNotFound() { try { WeatherServiceController WSController = new WeatherServiceController(); string result = WSController.GetWeatherData("citylist1sv.csv").Result; } catch (Exception ex) { Assert.AreEqual(typeof(FileNotFoundException), ex.InnerException.GetType()); } }