Exemplo n.º 1
0
        public void Every_nth_weekday(DayOfWeek n)
        {
            var cron     = CronTemplates.WeekDaily(n);
            var schedule = CrontabSchedule.Parse(cron);
            var diff     = CompareTwoCronOccurences(schedule);

            Assert.Equal(7, diff.Days);
        }
Exemplo n.º 2
0
        public void Every_nth_and_mth_weekday(DayOfWeek n, DayOfWeek m, int expected)
        {
            string          cron     = CronTemplates.WeekDaily(onDays: new[] { n, m });
            CrontabSchedule schedule = CrontabSchedule.Parse(cron);

            // These tests would be temporal if we used 'now', so must start from a known fixed date
            DateTime start = new DateTime(2016, 9, 4);
            DateTime from  = schedule.GetNextOccurrence(start); // should always start on 9/5/2016 (Monday)
            DateTime to    = schedule.GetNextOccurrence(from);
            TimeSpan diff  = to - from;

            Assert.Equal(expected, diff.Days);
        }