public void NextLeapYearCronScheduleShouldBePossible() { // starting july 2020 _now = new DateTime(2020, 07, 15, 16, 00, 00); // next should be thursday 12:00 var next = new DateTime(2024, 02, 29, 12, 00, 00); var schedule = new CronSchedule($"* * 12 29 02 *"); var time = schedule.NextSchedule(_now); Assert.Equal(next, time); }
public void NextSundayHighNoonCronScheduleShouldBeInExpectedSpan() { while (_now.DayOfWeek != DayOfWeek.Wednesday) { _now += TimeSpan.FromDays(1); } var next = new DateTime(_now.Year, _now.Month, _now.Day, 12, 00, 00); do { next += TimeSpan.FromDays(1); } while(next.DayOfWeek != DayOfWeek.Sunday); var schedule = new CronSchedule($"00 00 12 * * SUN"); var time = schedule.NextSchedule(_now); Assert.Equal(next, time); }
public void FromWednesdayNextTuesdayToSaturdayHighNoonCronScheduleShouldBeOnThursday() { // starting on wednesday 16:00 _now = new DateTime(_now.Year, _now.Month, _now.Day, 16, 00, 00); while (_now.DayOfWeek != DayOfWeek.Wednesday) { _now += TimeSpan.FromDays(1); } // next should be thursday 12:00 var next = new DateTime(_now.Year, _now.Month, _now.Day, 12, 00, 00); do { next += TimeSpan.FromDays(1); } while(next.DayOfWeek != DayOfWeek.Thursday); var schedule = new CronSchedule($"00 00 12 * * TUE-SAT"); var time = schedule.NextSchedule(_now); Assert.Equal(next, time); }