Ejemplo n.º 1
0
        private string GetWeatherMessage(WeatherResponse weatherResponse)
        {
            var result = string.Empty;

            try
            {
                var response = weatherResponse.Query.Result.Channel;

                var temperature = response.Units.Temperature == "F"
                    ? $"{_unitsConverterFactory.Convert(ConverterType.Temperature, response.Item.Condition.Temperature)}°C"
                    : $"{response.Item.Condition.Temperature}°{response.Units.Temperature}";

                var wind = response.Units.Speed == "mph"
                    ? $"{_unitsConverterFactory.Convert(ConverterType.Speed, response.Wind.Speed)} km/h"
                    : $"{response.Wind.Speed} {response.Units.Speed}";

                var windDirection = _unitsConverterFactory.Convert(ConverterType.DegreeToDirection,
                                                                   response.Wind.Direction);

                var pressure = $"{response.Atmosphere.Pressure} millibars";

                result =
                    $"Now: {temperature}\n\r" +
                    $"{response.Item.Condition.Text}\n\r" +
                    $"Wind: {wind} " +
                    $"{windDirection}\n\r" +
                    $"Pressure: {pressure}\n\r" +
                    $"Humidity: {response.Atmosphere.Humidity}%";
            }
            catch (Exception ex)
            {
                _logger.Error("Get weather message error.", ex);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void Convert()
        {
            var result = _factory.Convert(ConverterType.Temperature, "70");

            Assert.Equal(result, 21d);
        }
Ejemplo n.º 3
0
        public void Convert()
        {
            var result = _factory.Convert(ConverterType.Pressure, "30");

            Assert.Equal(result, 1015.91);
        }
Ejemplo n.º 4
0
        public void Convert_North()
        {
            var result = _factory.Convert(ConverterType.DegreeToDirection, "0");

            Assert.Equal(result, "North");
        }
Ejemplo n.º 5
0
        public void Convert()
        {
            var result = _factory.Convert(ConverterType.Speed, "120");

            Assert.Equal(result, 193d);
        }