public WeatherData getWeatherData(Location location) { if (location._city_id != null) { WeatherData return_weather_data_cityId = ProcessResponse(RequestOpenWeather.BuildCompleteRequestStringForCityDataById(location._city_id, _doc_format.xml.ToString(), _mode_format.metric.ToString()), _mode_format.metric); if (return_weather_data_cityId == null) throw new WeatherDataServiceException("No data was fetch by ProcessResponse function using city ID"); return return_weather_data_cityId; } else { WeatherData return_city_data_city_name = ProcessResponse(RequestOpenWeather.BuildCompleteRequestStringForCityDataByName(location._city_name, _doc_format.xml.ToString(), _mode_format.metric.ToString()), _mode_format.metric); if (return_city_data_city_name == null) throw new WeatherDataServiceException("No data was fetch by ProcessResponse function using city name"); return return_city_data_city_name; } }
static void Main(string[] args) { Location newlocation = new Location("london"); IWeatherDataService open_map_weather = WeatherDataServiceFactory.getWeatherDataService(WeatherDataServiceFactory.OPEN_WEATHER_MAP); WeatherData opachki = open_map_weather.getWeatherData(newlocation); }
static void Main(string[] args) { Location newlocation = new Location("Israel"); IWeatherDataService open_map_weather = WeatherDataServiceFactory.getWeatherDataService(WeatherDataServiceFactory.OPEN_WEATHER_MAP); WeatherData opachki = open_map_weather.getWeatherData(newlocation); opachki.printAllCached(); Console.WriteLine(" Max temp " + opachki.max_temperatur + " Min temp " + opachki.min_temperatur + " temp " + opachki.value_temperatur); }
public void TestMethod1() { Location newlocation = new Location("Haim Michael !"); try { IWeatherDataService open_map_weather = WeatherDataServiceFactory.getWeatherDataService(WeatherDataServiceFactory.OPEN_WEATHER_MAP); } catch (Exception e) { Assert.AreEqual(e.Message,"No data was fetch by ProcessResponse function using city ID"); } }