public async Task GetWeatherInformation_WithCombinationOf_Valid_InvalidCityIdAsync() { WeatherReportsController weather = new WeatherReportsController(); CityInput cityInput = new CityInput(); cityInput.Cities = new List <City> { new City { id = 127539, //Invalid name = "Mumbai" }, new City { id = 1273294, //Valid name = "Delhi" }, new City { id = 29223, //Invalid name = "Dubai" } }; var result = await weather.PostAsync(cityInput); //Weather details corresponding to valid City id returns in list Assert.IsFalse(result.Count == 3); //Count is 1 }
public async Task GetWeatherInformation_WithMultipleValidCityIdAsync() { WeatherReportsController weather = new WeatherReportsController(); CityInput cityInput = new CityInput(); cityInput.Cities = new List <City> { new City { id = 1275339, name = "Mumbai" }, new City { id = 1273294, name = "Delhi" }, new City { id = 292223, name = "Dubai" } }; var result = await weather.PostAsync(cityInput); Assert.IsTrue(result.Count == 3); }
public async Task GetWeatherInformation_WithValidCityIdAsync() { WeatherReportsController weather = new WeatherReportsController(); CityInput cityInput = new CityInput(); cityInput.Cities = new List <City> { new City { id = 1275339, name = "Mumbai" } }; var result = await weather.PostAsync(cityInput); Assert.IsNotNull(result.FirstOrDefault().name, "Mumbai"); }
static void Main(string[] args) { try { WeatherReportsController weather = new WeatherReportsController(); Console.WriteLine("City File Received Location With Name : "); //Format :- C:\Users\nirashuk\source\repos\WeatherReport\Weather\FileReaderApplication\InputFile\Cities.json string inputPath = Console.ReadLine(); CityInput cityInput = new CityInput(); using (StreamReader r = new StreamReader(inputPath)) { string jsonFile = r.ReadToEnd(); cityInput = JsonConvert.DeserializeObject <CityInput>(jsonFile); } var result = weather.PostAsync(cityInput).GetAwaiter().GetResult(); Console.WriteLine("Enter Output Destination : "); //Format:- C:\Users\nirashuk\source\repos\WeatherReport\Weather\FileReaderApplication\OutputFile\ string outputPath = Console.ReadLine(); //Save received Output with city name and timestamp foreach (var weatherReport in result) { string serializedReport = JsonConvert.SerializeObject(weatherReport); File.WriteAllText(outputPath + weatherReport.name + "_" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + ".json", serializedReport); Console.WriteLine("Weather report " + weatherReport.name + "_" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + ".json" + " created successfully"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }