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_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 <List <WeatherReport> > PostAsync([FromBody] CityInput cityInput) { List <WeatherReport> weatherReportList = new List <WeatherReport>(); using (var handler = new HttpClientHandler()) using (var client = new HttpClient(handler)) { client.BaseAddress = new Uri("https://api.openweathermap.org/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); foreach (var city in cityInput.Cities) { var response = await client.GetAsync("/data/2.5/weather?id=" + city.id + "&appid=aa69195559bd4f88d79f9aadeb77a8f6"); if (response.IsSuccessStatusCode) { WeatherReport weatherReport = new WeatherReport(); weatherReport = await response.Content.ReadAsAsync <WeatherReport>(); weatherReportList.Add(weatherReport); } } return(weatherReportList); } }
public AddressFormComponent TypeInCityInput(string text) { CityInput.Click(); CityInput.Clear(); CityInput.SendKeys(text); return(this); }
public BillingOrderPage FillCity(string city) { CustomTestContext.WriteLine($"Fill city - '{city}'"); CityInput.SendKeys(city); return(this); }
private void FillAddressInfoInternal(Data.ClientPurchaseInfo clientInfo) { CountryDropDown.SelectByText(clientInfo.ShippingInfo.Country); FullNameInput.SendKeys(clientInfo.ShippingInfo.FullName); Address1Input.SendKeys(clientInfo.ShippingInfo.Address1); CityInput.SendKeys(clientInfo.ShippingInfo.City); ZipInput.SendKeys(clientInfo.ShippingInfo.Zip); PhoneInput.SendKeys(clientInfo.ShippingInfo.Phone); ShipToThisAddress.Click(); }
public void FindHotels() { Thread.Sleep(1000); WaitAndClick(CityInput); CityInput.SendKeys("Venice"); Thread.Sleep(3000); WaitAndClick(ConfirmCity); WaitAndClick(CheckInDate); WaitAndClick(CheckInDate); WaitAndClick(Day); WaitAndClick(LetsGoButton); }
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"); }
public CreateGroupPage CrearGroup(Group group) { foreach (var input in AllForm) { input.Clear(); } Thread.Sleep(1000); NameInput.SendKeys(group.Name); Thread.Sleep(1000); StartYearInput.SendKeys(group.StartYear.ToString()); Thread.Sleep(1000); EndYearInput.SendKeys(group.EndYear.ToString()); Thread.Sleep(1000); CountryInput.SendKeys(group.Country); Thread.Sleep(1000); CityInput.SendKeys(group.City); Thread.Sleep(1000); UrlWikiInput.SendKeys(group.URLWiki); Thread.Sleep(1000); DescriptionInput.SendKeys(group.Description); Thread.Sleep(1000); return(this); }
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); } }
public AddressFormComponent ClickCityInput() { CityInput.Click(); return(this); }