Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public void GetWeatherDataForCity_Throws_WhenTheRawResponseIsNull()
 {
     _darkSkyService = new DarkSkyService(_weatherDataRetrieverToReturnEmpty, _darkSkyConfigurationManager);
     Assert.ThrowsAsync <ArgumentNullException>(() => _darkSkyService.GetWeatherDataForCity(city));
 }
Esempio n. 4
0
 public void GetWeatherDataForCity_Throws_WhenCityIsNull()
 {
     _darkSkyService = new DarkSkyService(_weatherDataRetriever, _darkSkyConfigurationManager);
     Assert.ThrowsAsync <ArgumentNullException>(() => _darkSkyService.GetWeatherDataForCity(null));
 }