Exemplo n.º 1
0
        public void TestGetDateOffset_ByTimeZone(int y, int m, int d, String tz, DayLightDefinition daylight, Double expected)
        {
            var dd = new DateDefinition {
                Year     = y,
                Month    = m,
                Day      = d,
                TimeZone = TimeZoneInfo.FindSystemTimeZoneById(tz),
                DayLight = daylight
            };

            Assert.Equal(TimeSpan.FromHours(expected), dd.GetDateOffset());
        }
Exemplo n.º 2
0
        public void TestGetDateOffset_ByOffset(int y, int m, int d, Double off, DayLightDefinition daylight, Double expected)
        {
            var dd = new DateDefinition {
                Year      = y,
                Month     = m,
                Day       = d,
                UtcOffset = TimeSpan.FromHours(off),
                DayLight  = daylight
            };

            Assert.Equal(TimeSpan.FromHours(expected), dd.GetDateOffset());
        }
Exemplo n.º 3
0
        public virtual void OnPreLoad()
        {
            Tunings.Inject<Lot, VisitCommunityLot.Definition, Definition>(false);
            Tunings.Inject<Lot, VisitCommunityLot.DateDefinition, DateDefinition>(false);

            sOldSingleton = Singleton;
            sOldDateSingleton = DateSingleton;
            sNoAdditionalActionsSingleton = NoAdditionalActionsSingleton;

            Singleton = new Definition();
            DateSingleton = new DateDefinition();
            NoAdditionalActionsSingleton = new Definition(false);

            sAcceptableCommercialLotSubTypes = new List<CommercialLotSubType>(Sim.GoForWalkWithDog.kAcceptableCommercialLotSubTypes);
        }
Exemplo n.º 4
0
        public virtual void OnPreLoad()
        {
            Tunings.Inject <Lot, VisitCommunityLot.Definition, Definition>(false);
            Tunings.Inject <Lot, VisitCommunityLot.DateDefinition, DateDefinition>(false);

            sOldSingleton                 = Singleton;
            sOldDateSingleton             = DateSingleton;
            sNoAdditionalActionsSingleton = NoAdditionalActionsSingleton;

            Singleton     = new Definition();
            DateSingleton = new DateDefinition();
            NoAdditionalActionsSingleton = new Definition(false);

            sAcceptableCommercialLotSubTypes = new List <CommercialLotSubType>(Sim.GoForWalkWithDog.kAcceptableCommercialLotSubTypes);
        }
Exemplo n.º 5
0
        public void TestSetDateTime()
        {
            DateDefinition def = new DateDefinition(DateTimeOffset.Now);

            Assert.Equal(TimeZoneInfo.Local.GetUtcOffset(DateTimeOffset.Now), def.UtcOffset);
            Assert.Equal(null, def.TimeZone);

            def.SetDate(new DateTime(2015, 6, 3, 6, 6, 23, 123, DateTimeKind.Unspecified));
            Assert.Equal(2015, def.Year);
            Assert.Equal(6, def.Month);
            Assert.Equal(3, def.Day);
            Assert.Equal(6, def.Hour);
            Assert.Equal(6, def.Minute);
            Assert.Equal(23, def.Second);
            Assert.Equal(123, def.MilliSecond);
            Assert.Equal(TimeSpan.FromHours(0), def.UtcOffset);
            Assert.Same(TimeZoneInfo.Local, def.TimeZone);
            Assert.Equal(DayLightDefinition.FromTimeZone, def.DayLight);
        }
Exemplo n.º 6
0
        public void TestEquals()
        {
            DateTimeOffset now = DateTimeOffset.Now;
            DateDefinition def = new DateDefinition(now);

            Assert.False(def.Equals((DateDefinition)null));
            Assert.True(def.Equals(def));
            Assert.True(def.Equals(new DateDefinition(now)));
            Assert.False(def.Equals(new DateDefinition(now, DayLightDefinition.On)));
            Assert.False(def.Equals(new DateDefinition(now.ToUniversalTime())));
            Assert.False(def.Equals(new DateDefinition(now.DateTime)));
            Assert.False(def.Equals(new DateDefinition(now.DateTime.ToUniversalTime())));

            def = new DateDefinition(now.DateTime);
            Assert.False(def.Equals(new DateDefinition(now)));
            Assert.False(def.Equals(new DateDefinition(now, DayLightDefinition.On)));
            Assert.False(def.Equals(new DateDefinition(now.ToUniversalTime())));
            Assert.True(def.Equals(new DateDefinition(now.DateTime)));
            Assert.False(def.Equals(new DateDefinition(now.DateTime.ToUniversalTime())));
        }
Exemplo n.º 7
0
        public void TestCreate()
        {
            var dd = new DateDefinition();

            Assert.Equal(0, dd.Year);
            Assert.Equal(0, dd.Month);
            Assert.Equal(0, dd.Day);
            Assert.Equal(0, dd.Hour);
            Assert.Equal(0, dd.Minute);
            Assert.Equal(0, dd.Second);
            Assert.Equal(0, dd.MilliSecond);
            Assert.Equal(TimeSpan.Zero, dd.UtcOffset);
            Assert.Equal(null, dd.TimeZone);
            Assert.Equal(DayLightDefinition.FromTimeZone, dd.DayLight);

            dd = new DateDefinition(new DateTimeOffset(2015, 6, 3, 6, 6, 23, 123, TimeSpan.FromHours(3)), DayLightDefinition.Off);
            Assert.Equal(2015, dd.Year);
            Assert.Equal(6, dd.Month);
            Assert.Equal(3, dd.Day);
            Assert.Equal(6, dd.Hour);
            Assert.Equal(6, dd.Minute);
            Assert.Equal(23, dd.Second);
            Assert.Equal(123, dd.MilliSecond);
            Assert.Equal(TimeSpan.FromHours(3), dd.UtcOffset);
            Assert.Equal(null, dd.TimeZone);
            Assert.Equal(DayLightDefinition.Off, dd.DayLight);

            dd = new DateDefinition(new DateTime(2015, 6, 3, 6, 6, 23, 123, DateTimeKind.Utc), DayLightDefinition.On);
            Assert.Equal(2015, dd.Year);
            Assert.Equal(6, dd.Month);
            Assert.Equal(3, dd.Day);
            Assert.Equal(6, dd.Hour);
            Assert.Equal(6, dd.Minute);
            Assert.Equal(23, dd.Second);
            Assert.Equal(123, dd.MilliSecond);
            Assert.Equal(TimeSpan.FromHours(0), dd.UtcOffset);
            Assert.Same(TimeZoneInfo.Utc, dd.TimeZone);
            Assert.Equal(DayLightDefinition.On, dd.DayLight);
        }
Exemplo n.º 8
0
        public void TestToJulianDay()
        {
            var mockProvider = new Mock <IEphemerisProvider>();
            var provider     = mockProvider.Object;

            DateDefinition dd = new DateDefinition {
                Year  = 2015,
                Month = 6,
                Day   = 7
            };
            var jd = provider.ToJulianDay(dd, DateCalendar.Gregorian);

            Assert.Equal(0, jd);
            jd = provider.ToJulianDay(dd, DateCalendar.Julian);
            Assert.Equal(0, jd);

            mockProvider.Verify(p => p.ToJulianDay(It.IsAny <DateTimeOffset>(), DateCalendar.Gregorian), Times.Once());
            mockProvider.Verify(p => p.ToJulianDay(It.IsAny <DateTimeOffset>(), DateCalendar.Julian), Times.Once());

            Assert.Throws <ArgumentNullException>(() => EphemerisProviderExtensions.ToJulianDay(null, null));
            Assert.Throws <ArgumentNullException>(() => EphemerisProviderExtensions.ToJulianDay(provider, null));
        }
Exemplo n.º 9
0
        public void TestToDateTime_ByTimeZone(int y, int m, int d, String tz, DayLightDefinition daylight, Double?expected)
        {
            var dd = new DateDefinition {
                Year     = y,
                Month    = m,
                Day      = d,
                TimeZone = TimeZoneInfo.FindSystemTimeZoneById(tz),
                DayLight = daylight
            };

            if (expected.HasValue)
            {
                var dto = dd.ToDateTime();
                Assert.Equal(y, dto.Year);
                Assert.Equal(m, dto.Month);
                Assert.Equal(d, dto.Day);
                //Assert.Equal(expected, dto.Offset.TotalHours);
            }
            else
            {
                Assert.Throws <ArgumentOutOfRangeException>(() => dd.ToDateTime());
            }
        }
Exemplo n.º 10
0
        public void TestToDateTime_ByOffset(int y, int m, int d, Double off, DayLightDefinition daylight, Double?expected)
        {
            var dd = new DateDefinition {
                Year      = y,
                Month     = m,
                Day       = d,
                UtcOffset = TimeSpan.FromHours(off),
                DayLight  = daylight
            };

            if (expected.HasValue)
            {
                var dto = dd.ToDateTime();
                Assert.Equal(y, dto.Year);
                Assert.Equal(m, dto.Month);
                Assert.Equal(d, dto.Day);
                //Assert.Equal(expected, dto.Offset.TotalHours);
            }
            else
            {
                Assert.Throws <ArgumentOutOfRangeException>(() => dd.ToDateTime());
            }
        }