public void DailyOccurrenceOutOfRangeTest() { var occ = new DailyOccurrence(twentyDaysAgo, tenDaysAgo, 1); Assert.IsNull(occ.GetNext(today)); Assert.IsNull(occ.GetNext(today, true)); var futureOcc = new DailyOccurrence(today.AddDays(20), today.AddDays(30), 1); Assert.IsNull(futureOcc.GetNext(today)); var nextOccPastEnd = new DailyOccurrence(today.AddDays(20), today.AddDays(31), 4); visualiseOccurrencesInRange(nextOccPastEnd, today.AddDays(15), today.AddDays(38)); Assert.IsNull(nextOccPastEnd.GetNext(today.AddDays(30))); Assert.IsNotNull(nextOccPastEnd.GetNext(today.AddDays(26)).Value); }
public void WeeklyOccurrenceMultipleDaysTest() { var start = new DateTime(2010, 6, 3); var end = new DateTime(2010, 8, 13); var days = new[] { DayOfWeek.Sunday, DayOfWeek.Saturday }; var occ = new WeeklyOccurrence(start, end, days, 2); Assert.AreEqual(new DateTime(2010, 6, 5), occ.GetNext(start)); Assert.AreEqual(new DateTime(2010, 6, 5), occ.GetNext(start)); Assert.AreEqual(new DateTime(2010, 6, 5), occ.GetNext(start.AddDays(1))); Assert.AreEqual(new DateTime(2010, 6, 5), occ.GetNext(new DateTime(2010, 6, 5))); Assert.AreEqual(new DateTime(2010, 6, 6), occ.GetNext(new DateTime(2010, 6, 6))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 7))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 8))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 9))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 10))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 11))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 12))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 13))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 14))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 15))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 16))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 17))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 18))); Assert.AreEqual(new DateTime(2010, 6, 19), occ.GetNext(new DateTime(2010, 6, 19))); Assert.AreEqual(new DateTime(2010, 6, 20), occ.GetNext(new DateTime(2010, 6, 20))); Assert.AreEqual(new DateTime(2010, 7, 3), occ.GetNext(new DateTime(2010, 6, 21))); visualiseOccurrencesInRange(occ); Assert.IsNull(occ.GetNext(today)); var docc = new DailyOccurrence(new DateTime(2010, 6, 5), end, 14); Assert.AreEqual(new DateTime(2010, 6, 19), docc.GetNext(new DateTime(2010, 6, 19))); }