Ejemplo n.º 1
0
 public async Task TestGetDescriptionDaDkLanguage()
 {
     var provider = new WeatherService(new TestMock("Assets/TestData/WeatherId800.json"), new CultureInfo("da-DK"));
     var result = await provider.GetWeatherDataForCity("copenhagen");
     Assert.IsNotNull(result);
     Assert.AreEqual("skyfrit", result.Description);
 }
Ejemplo n.º 2
0
 public async Task TestGetDescriptionDefaultLanguage()
 {
     var provider = new WeatherService(new TestMock("Assets/TestData/WeatherId800.json"));
     var result = await provider.GetWeatherDataForCity("copenhagen");
     Assert.IsNotNull(result);
     Assert.AreEqual("Sky is Clear", result.Description);
 }
Ejemplo n.º 3
0
        private async Task RefreshWeatherData()
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                var weather = new WeatherService(ApplicationDataController.GetValue(KeyNames.OpenWeatherMapApiKey, string.Empty), new CultureInfo(ApplicationLanguages.PrimaryLanguageOverride));
                WeatherData weatherData = null;
                try
                {
                    //weatherData = await weather.GetWeatherDataForCity(ApplicationDataController.GetValue(KeyNames.WeatherZip, string.Empty), ApplicationDataController.GetValue(KeyNames.WeatherCountry, string.Empty));
                    weatherData = await weather.GetWeatherDataForCity(ApplicationDataController.GetValue(KeyNames.WeatherCityName, string.Empty));
                }
                catch (WeatherServiceException weatherServiceException)
                {
                    await ShowMessageDialogIfSupported(weatherServiceException.Message, "Error");
                }

                if (weatherData == null)
                {
                    await ShowMessageDialogIfSupported(Strings.UnableToConnectToWeatherService, Strings.Error);
                }
                else
                {
                    WeatherIcon.Source = GetImageSourceFromUri(weatherData.WeatherIconUri.AbsolutePath);
                    LocationTxb.Text = Strings.Get(weatherData.Location);
                    if (string.IsNullOrEmpty(LocationTxb.Text))
                        LocationTxb.Text = weatherData.Location;
                    TemperatureTxb.Text = Math.Round(weatherData.Temp) + "°";
                    WeatherDescirptionTxb.Text = string.IsNullOrEmpty(weatherData.Description) ? string.Empty : weatherData.Description.ToLower();
                }
            });
        }