public void TestExclusionAndNextIncludedTime() { cal.DaysExcluded = null; DateTimeOffset test = DateTimeOffset.UtcNow.Date; Assert.AreEqual(test, cal.GetNextIncludedTimeUtc(test), "Did not get today as date when nothing was excluded"); cal.SetDayExcluded(test.Date, true); Assert.AreEqual(test.AddDays(1), cal.GetNextIncludedTimeUtc(test), "Did not get next day when current day excluded"); }
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); }