private async Task LoadData() { if (_requiredListOfCities != null) { return; } _requiredListOfCities = _cityService.AvilableCities; try { //could be split to different chunks as well like 2 each or sg. foreach (City city in _requiredListOfCities) { WeatherDataRoot weatherInfo = await _darkSkyService.GetWeatherDataForCity(city); AvailableWeatherInfo.Add(weatherInfo); } //testing what is quicker in terms of loading data -> one by one is fine. //IEnumerable<WeatherDataRoot> availableWeatherInfo = await _darkSkyService.GetWeatherDataForMultipleCities(_requiredListOfCities); //AvailableWeatherInfo = new ObservableCollection<WeatherDataRoot>(availableWeatherInfo); } catch (Exception ex) { IsThereAConnectionError = true; Logger.Error("An error occured while getting data from the Dark Sky Service. Please check details in the log.", ex); } }
public async Task GetWeatherDataForCity_SuccessfullyParses_NormalJSONString() { _darkSkyService = new DarkSkyService(_weatherDataRetriever, _darkSkyConfigurationManager); WeatherDataRoot weatherData = await _darkSkyService.GetWeatherDataForCity(city); Assert.IsNotNull(weatherData); Assert.IsNotNull(weatherData.CurrentWeather); Assert.AreEqual(weatherData.CurrentWeather.Temperature, -1.73); Assert.AreEqual(weatherData.CurrentWeather.Icon, IconValue.CLOUDY); Assert.AreEqual(weatherData.CurrentWeather.Humidity, 0.96); }
public void GetWeatherDataForCity_Throws_WhenTheRawResponseIsNull() { _darkSkyService = new DarkSkyService(_weatherDataRetrieverToReturnEmpty, _darkSkyConfigurationManager); Assert.ThrowsAsync <ArgumentNullException>(() => _darkSkyService.GetWeatherDataForCity(city)); }
public void GetWeatherDataForCity_Throws_WhenCityIsNull() { _darkSkyService = new DarkSkyService(_weatherDataRetriever, _darkSkyConfigurationManager); Assert.ThrowsAsync <ArgumentNullException>(() => _darkSkyService.GetWeatherDataForCity(null)); }