Пример #1
0
        public void TestDayExclusion()
        {
            // we're local by default
            DateTime d = new DateTime(2005, 1, 1);

            cal.SetDayExcluded(d, true);
            Assert.IsFalse(cal.IsTimeIncluded(d.ToUniversalTime()), "Time was included when it was supposed not to be");
            Assert.IsTrue(cal.IsDayExcluded(d), "Day was not excluded when it was supposed to be excluded");
            Assert.AreEqual(1, cal.DaysExcluded.Count);
            Assert.AreEqual(d.Day, cal.DaysExcluded.First().Day);
            Assert.AreEqual(d.Month, cal.DaysExcluded.First().Month);
        }
Пример #2
0
        public void TestAnnualCalendarTimeZone()
        {
            TimeZoneInfo   tz = TimeZoneUtil.FindTimeZoneById("Eastern Standard Time");
            AnnualCalendar c  = new AnnualCalendar();

            c.TimeZone = tz;

            DateTime excludedDay = new DateTime(2012, 11, 4, 0, 0, 0);

            c.SetDayExcluded(excludedDay, true);

            // 11/5/2012 12:00:00 AM -04:00  translate into 11/4/2012 11:00:00 PM -05:00 (EST)
            DateTimeOffset date = new DateTimeOffset(2012, 11, 5, 0, 0, 0, TimeSpan.FromHours(-4));

            Assert.IsFalse(c.IsTimeIncluded(date), "date was expected to not be included.");
            Assert.IsTrue(c.IsTimeIncluded(date.AddDays(1)));

            DateTimeOffset expectedNextAvailable = new DateTimeOffset(2012, 11, 5, 0, 0, 0, TimeSpan.FromHours(-5));
            DateTimeOffset actualNextAvailable   = c.GetNextIncludedTimeUtc(date);

            Assert.AreEqual(expectedNextAvailable, actualNextAvailable);
        }