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 TestKelvinToFahrenheit()
        {
            var temperatureConverter = new TemperatureConverter();

            temperatureConverter.SetTemperature(278.15);
            Assert.AreEqual(41.0, temperatureConverter.KelvinToFahrenheit());
        }
Beispiel #3
0
        public void KelvinToFahrenheit(decimal temperature, decimal expected)
        {
            // Arrange
            var temperatureConverter = new TemperatureConverter();

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

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