示例#1
0
        public void Every_n_days(int n)
        {
            var cron     = CronTemplates.Daily(n);
            var schedule = CronTemplates.Parse(cron);
            var diff     = CompareTwoCronOccurrences(schedule);

            Assert.Equal(n, diff.Days);
        }
示例#2
0
        public void Every_nth_weekday(DayOfWeek n)
        {
            var cron     = CronTemplates.Weekly(n);
            var schedule = CronTemplates.Parse(cron);
            var diff     = CompareTwoCronOccurrences(schedule);

            Assert.Equal(7, diff.Days);
        }
示例#3
0
        public void Monthly_on_first_of_month()
        {
            var cron     = CronTemplates.Monthly();
            var schedule = CronTemplates.Parse(cron);
            var diff     = CompareTwoCronOccurrences(schedule);

            Assert.True(diff.Days == 30 || diff.Days == 31);
        }
示例#4
0
        public void Every_nth_and_mth_weekday(DayOfWeek n, DayOfWeek m, int expected)
        {
            var cron     = CronTemplates.Weekly(onDays: new[] { n, m });
            var schedule = CronTemplates.Parse(cron);

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

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