Exemplo n.º 1
0
        public MappingProfile()
        {
            // Current
            CreateMap <OpenWeathermapCurrent, Weather>(MemberList.Destination)
            .ForMember(x => x.DateTime, o =>
                       o.MapFrom(y => DateTimeUTC.FromSecondsSinceUnixEpoch(y.dt)))
            .ForMember(x => x.CloudDescription, o => o.MapFrom(y => y.weather[0].description))
            .ForMember(x => x.FeelsLikeTemperature, o => o.MapFrom(y => y.main.feels_like))
            .ForMember(x => x.Humidity, o => o.MapFrom(y => y.main.humidity))
            .ForMember(x => x.MaximumTemperature, o => o.MapFrom(y => y.main.temp_max))
            .ForMember(x => x.MinimumTemperature, o => o.MapFrom(y => y.main.temp_min))
            .ForMember(x => x.Pressure, o => o.MapFrom(y => y.main.pressure))
            .ForMember(x => x.Temperature, o => o.MapFrom(y => y.main.temp))
            .ForMember(x => x.WindDirection, o => o.MapFrom(y => y.wind.deg))
            .ForMember(x => x.Windspeed, o => o.MapFrom(y => y.wind.speed))
            .ForMember(x => x.Icon, o => o.MapFrom(y => y.weather[0].icon));

            // Forecast
            CreateMap <WeatherList, Weather>(MemberList.Destination)
            .ForMember(x => x.DateTime, o =>
                       o.MapFrom(y => DateTimeUTC.FromSecondsSinceUnixEpoch(y.dt)))
            .ForMember(x => x.CloudDescription, o => o.MapFrom(y => y.weather[0].description))
            .ForMember(x => x.FeelsLikeTemperature, o => o.MapFrom(y => y.main.feels_like))
            .ForMember(x => x.Humidity, o => o.MapFrom(y => y.main.humidity))
            .ForMember(x => x.MaximumTemperature, o => o.MapFrom(y => y.main.temp_max))
            .ForMember(x => x.MinimumTemperature, o => o.MapFrom(y => y.main.temp_min))
            .ForMember(x => x.Pressure, o => o.MapFrom(y => y.main.pressure))
            .ForMember(x => x.Temperature, o => o.MapFrom(y => y.main.temp))
            .ForMember(x => x.WindDirection, o => o.MapFrom(y => y.wind.deg))
            .ForMember(x => x.Windspeed, o => o.MapFrom(y => y.wind.speed))
            .ForMember(x => x.Icon, o => o.MapFrom(y => y.weather[0].icon));
        }
Exemplo n.º 2
0
        public void TestUTCFromOpenWeathermap()
        {
            DateTime result = DateTimeUTC.FromSecondsSinceUnixEpoch(1596358800);

            Assert.Equal(new DateTime(2020, 8, 2, 9, 0, 0), result);

            result = DateTimeUTC.FromSecondsSinceUnixEpoch(1596369600);
            Assert.Equal(new DateTime(2020, 8, 2, 12, 0, 0), result);

            result = DateTimeUTC.FromSecondsSinceUnixEpoch(1596380400);
            Assert.Equal(new DateTime(2020, 8, 2, 15, 0, 0), result);
        }
Exemplo n.º 3
0
        public void TestPositiveUTC()
        {
            DateTime result = DateTimeUTC.FromSecondsSinceUnixEpoch(secondsPerDay);

            Assert.Equal(new DateTime(1970, 1, 1).AddDays(1), result);
        }
Exemplo n.º 4
0
        public void TestBeginOfTime()
        {
            DateTime result = DateTimeUTC.FromSecondsSinceUnixEpoch(0);

            Assert.Equal(new DateTime(1970, 1, 1), result);
        }