コード例 #1
0
        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);
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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);
                }
        }
コード例 #4
0
ファイル: AddressFormComponent.cs プロジェクト: orest77/Test
 public AddressFormComponent TypeInCityInput(string text)
 {
     CityInput.Click();
     CityInput.Clear();
     CityInput.SendKeys(text);
     return(this);
 }
コード例 #5
0
        public BillingOrderPage FillCity(string city)
        {
            CustomTestContext.WriteLine($"Fill city - '{city}'");
            CityInput.SendKeys(city);

            return(this);
        }
コード例 #6
0
 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();
 }
コード例 #7
0
 public void FindHotels()
 {
     Thread.Sleep(1000);
     WaitAndClick(CityInput);
     CityInput.SendKeys("Venice");
     Thread.Sleep(3000);
     WaitAndClick(ConfirmCity);
     WaitAndClick(CheckInDate);
     WaitAndClick(CheckInDate);
     WaitAndClick(Day);
     WaitAndClick(LetsGoButton);
 }
コード例 #8
0
        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");
        }
コード例 #9
0
 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);
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: nirashuk/WeatherReport
        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);
            }
        }
コード例 #11
0
ファイル: AddressFormComponent.cs プロジェクト: orest77/Test
 public AddressFormComponent ClickCityInput()
 {
     CityInput.Click();
     return(this);
 }