Beispiel #1
0
        public async Task <string> GetWeatherAsync(string country, string city)
        {
            WeatherServiceRef.GlobalWeatherSoap obj = new WeatherServiceRef.GlobalWeatherSoapClient();
            var forecast = await obj.GetWeatherAsync(country, city);

            if (forecast.IndexOf("Data Not Found") >= 0)
            {
                //no data available build a mock object
                var fc = new Forecast()
                {
                    Location   = "Mock Location",
                    Time       = DateTime.Now.AddDays(1).ToShortDateString(),
                    Wind       = "16km/h",
                    Visibility = "yes",
                    Sky        = "cloudy",
                    Temp       = "20 degree",
                    Dew        = "16 degree",
                    Humidity   = "80%",
                    Presurre   = "1000hpa"
                };
                return(JsonConvert.SerializeObject(fc).ToString());
            }
            else
            {
                return(JsonHelper.processWeatherResult(forecast));
            }
        }
Beispiel #2
0
        public async Task WeatherServiceTest()
        {
            WeatherServiceRef.GlobalWeatherSoap obj = new WeatherServiceRef.GlobalWeatherSoapClient();
            var weather = await obj.GetWeatherAsync("Australia", "Sydney Airport");

            Assert.IsNotNull(weather);
        }
Beispiel #3
0
        public async Task CityServiceTest()
        {
            WeatherServiceRef.GlobalWeatherSoap obj = new WeatherServiceRef.GlobalWeatherSoapClient();
            var cities = await obj.GetCitiesByCountryAsync("Australia");

            Assert.IsNotNull(cities);
            Assert.IsTrue(cities.IndexOf("Sydney") >= 0);
        }
        public async Task <string> GetCitiesAsync(string country)
        {
            WeatherServiceRef.GlobalWeatherSoap obj = new WeatherServiceRef.GlobalWeatherSoapClient();
            var cities = await obj.GetCitiesByCountryAsync(country);

            var json = JsonHelper.processWeatherResult(cities);

            return(json);
        }