private WeatherConditions GetResult(string json, Location location)
        {
            var weatherDto = JsonConvert.DeserializeObject <WeatherDto>(json);

            if (weatherDto == null)
            {
                return(null);
            }

            var weatherConditions = new WeatherConditions()
            {
                Title          = weatherDto.Title,
                Description    = weatherDto.Description,
                TemperatureC   = (int)Math.Ceiling(TemperatureConverter.KelvinToCelsius(weatherDto.Main.Temperature)),
                TemperatureF   = (int)Math.Ceiling(TemperatureConverter.KelvinToFahrenheit(weatherDto.Main.Temperature)),
                Icon           = Icons.GetCssClass(weatherDto.IconCode),
                Location       = location.City,
                CountryCode    = location.CountryCode,
                UsesFahrenheit = location.UsesFahrenheit,
                Service        = "OpenWeatherMap",
                ServiceUrl     = "http://openweathermap.org/"
            };

            return(weatherConditions);
        }
Beispiel #2
0
        public void KelvinToCelsius(decimal temperature, decimal expected)
        {
            // Arrange
            var temperatureConverter = new TemperatureConverter();

            // Act
            var result = temperatureConverter.KelvinToCelsius(temperature);

            // Assert
            result.Should().Be(expected);
        }