public void AllDaysOfFirstWeekOfEachMonthForTwoMonths() { // arrange var schedule = new MonthlySchedule { // The first week OrdinalWeek = 1, // from 3 to 3:15PM Time = new TimeRange { Start = new Time { Hour = 15, Minute = 0 }, End = new Time { Hour = 15, Minute = 15 } }, // every month Frequency = 1, // for two months Duration = new DateRange { Start = new DateTime(2013, 1, 1), End = new DateTime(2013, 2, 28) } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(7, results.Count()); Assert.AreEqual(new DateTime(2013, 1, 1, 15, 0, 0), results.ElementAt(0).AsDateRange().Start, "First entry should be for Tues, January 1 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 1, 15, 15, 0), results.ElementAt(0).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 2, 15, 0, 0), results.ElementAt(1).AsDateRange().Start, "Second entry should be for Wed, January 2 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 2, 15, 15, 0), results.ElementAt(1).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 3, 15, 0, 0), results.ElementAt(2).AsDateRange().Start, "Third entry should be for Thurs, January 3 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 3, 15, 15, 0), results.ElementAt(2).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 4, 15, 0, 0), results.ElementAt(3).AsDateRange().Start, "Fourth entry should be for Fri, January 4 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 4, 15, 15, 0), results.ElementAt(3).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 5, 15, 0, 0), results.ElementAt(4).AsDateRange().Start, "Fifth entry should be for Sat, January 5 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 5, 15, 15, 0), results.ElementAt(4).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 1, 15, 0, 0), results.ElementAt(5).AsDateRange().Start, "Sixth entry should be for Fri, Feb 1 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 1, 15, 15, 0), results.ElementAt(5).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 2, 15, 0, 0), results.ElementAt(6).AsDateRange().Start, "Seventh entry should be for Sat, Feb 2 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 2, 15, 15, 0), results.ElementAt(6).AsDateRange().End); }
public void FirstDayOfTheMonthForTwoMonthsStartingMidMonth() { // arrange var schedule = new MonthlySchedule { // on the first day OrdinalDay = 1, // from 11:15AM to 3:45PM Time = new TimeRange { Start = new Time { Hour = 11, Minute = 15 }, End = new Time { Hour = 15, Minute = 45 } }, // each month Frequency = 1, // for two months, starting not on the first Duration = new DateRange { Start = new DateTime(2013, 2, 9), End = new DateTime(2013, 3, 31) } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(1, results.Count()); Assert.AreEqual(new DateTime(2013, 3, 1, 11, 15, 0), results.ElementAt(0).AsDateRange().Start, "First entry should be for March 1"); Assert.AreEqual(new DateTime(2013, 3, 1, 15, 45, 0), results.ElementAt(0).AsDateRange().End); }
public void ThirdDayOfEachMonthForThreeMonths() { // arrange var schedule = new MonthlySchedule { // on the third day OrdinalDay = 3, // from 11:15AM to 3:45PM Time = new TimeRange { Start = new Time { Hour = 11, Minute = 15 }, End = new Time { Hour = 15, Minute = 45 } }, // each month Frequency = 1, // for three months Duration = new DateRange { Start = new DateTime(2013, 1, 1), End = new DateTime(2013, 3, 3) // include March 3 in the range } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(3, results.Count()); Assert.AreEqual(new DateTime(2013, 1, 3, 11, 15, 0), results.ElementAt(0).AsDateRange().Start, "First entry should be for Thurs, January 3 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 1, 3, 15, 45, 0), results.ElementAt(0).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 3, 11, 15, 0), results.ElementAt(1).AsDateRange().Start, "Second entry should be for Sunday, Feb 3 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 2, 3, 15, 45, 0), results.ElementAt(1).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 3, 3, 11, 15, 0), results.ElementAt(2).AsDateRange().Start, "Third entry should be for Sunday, March 3 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 3, 3, 15, 45, 0), results.ElementAt(2).AsDateRange().End); }
public void SecondWeekOfEachMonthStartingMidMonth() { // arrange var schedule = new MonthlySchedule { // from 3 to 3:15PM Time = new TimeRange { Start = new Time { Hour = 15, Minute = 0 }, End = new Time { Hour = 15, Minute = 15 } }, // of the second week OrdinalWeek = 2, // every month Frequency = 1, // for two months, starting past the first Duration = new DateRange { Start = new DateTime(2013, 1, 9), End = new DateTime(2013, 2, 28) } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(14, results.Count()); }
public void SecondSaturdayEveryOtherMonthForSixMonths() { // arrange var schedule = new MonthlySchedule { // The second Saturday OrdinalDay = 2, Day = DayOfWeek.Saturday, // from 11:15AM to 3:45PM Time = new TimeRange { Start = new Time { Hour = 11, Minute = 15 }, End = new Time { Hour = 15, Minute = 45 } }, // every other month Frequency = 2, // for six months Duration = new DateRange { Start = new DateTime(2013, 1, 1), End = new DateTime(2013, 6, 30) // Include May, and June as well to prove we can specify a wider than necessary range and not get extra entries. } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(3, results.Count()); Assert.AreEqual(new DateTime(2013, 1, 12, 11, 15, 0), results.ElementAt(0).AsDateRange().Start, "First entry should be for Sat, January 21 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 1, 12, 15, 45, 0), results.ElementAt(0).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 3, 9, 11, 15, 0), results.ElementAt(1).AsDateRange().Start, "Second entry should be for Sat, March 9 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 3, 9, 15, 45, 0), results.ElementAt(1).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 5, 11, 11, 15, 0), results.ElementAt(2).AsDateRange().Start, "Third entry should be for Sat, May 11 at 11:15AM"); Assert.AreEqual(new DateTime(2013, 5, 11, 15, 45, 0), results.ElementAt(2).AsDateRange().End); }
public void OnlyWorkdaysOfSecondWeekOfEachMonthForTwoMonths() { // arrange var schedule = new MonthlySchedule { // only workdays OnlyWorkDays = true, // from 3 to 3:15PM Time = new TimeRange { Start = new Time { Hour = 15, Minute = 0 }, End = new Time { Hour = 15, Minute = 15 } }, // of the second week OrdinalWeek = 2, // every month Frequency = 1, // for two months Duration = new DateRange { Start = new DateTime(2013, 1, 1), End = new DateTime(2013, 2, 28) } }; // act var results = schedule.BuildSchedule(); // assert Assert.NotNull(results); Assert.AreEqual(10, results.Count()); Assert.AreEqual(new DateTime(2013, 1, 7, 15, 0, 0), results.ElementAt(0).AsDateRange().Start, "First entry should be for Monday, January 7 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 7, 15, 15, 0), results.ElementAt(0).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 8, 15, 0, 0), results.ElementAt(1).AsDateRange().Start, "Second entry should be for Tues, January 8 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 8, 15, 15, 0), results.ElementAt(1).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 9, 15, 0, 0), results.ElementAt(2).AsDateRange().Start, "Third entry should be for Wed, January 9 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 9, 15, 15, 0), results.ElementAt(2).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 10, 15, 0, 0), results.ElementAt(3).AsDateRange().Start, "Fourth entry should be for Thurs, January 10 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 10, 15, 15, 0), results.ElementAt(3).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 1, 11, 15, 0, 0), results.ElementAt(4).AsDateRange().Start, "Fifth entry should be for Fri, January 11 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 1, 11, 15, 15, 0), results.ElementAt(4).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 4, 15, 0, 0), results.ElementAt(5).AsDateRange().Start, "Sixth entry should be for Mon, Feb 4 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 4, 15, 15, 0), results.ElementAt(5).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 5, 15, 0, 0), results.ElementAt(6).AsDateRange().Start, "Seventh entry should be for Tues, Feb 5 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 5, 15, 15, 0), results.ElementAt(6).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 6, 15, 0, 0), results.ElementAt(7).AsDateRange().Start, "Eigth entry should be for Wed, Feb 6 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 6, 15, 15, 0), results.ElementAt(7).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 7, 15, 0, 0), results.ElementAt(8).AsDateRange().Start, "Ninth entry should be for Thurs, Feb 7 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 7, 15, 15, 0), results.ElementAt(8).AsDateRange().End); Assert.AreEqual(new DateTime(2013, 2, 8, 15, 0, 0), results.ElementAt(9).AsDateRange().Start, "Tenth entry should be for Fri, Feb 8 at 3:00PM"); Assert.AreEqual(new DateTime(2013, 2, 8, 15, 15, 0), results.ElementAt(9).AsDateRange().End); }