Exemple #1
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);
        }
Exemple #2
0
        public async Task <IActionResult> CreateWeeklyBackgroundTask([FromBody] CreateBackgroundTaskModel model,
                                                                     [FromRoute] DayOfWeek dayOfWeek = DayOfWeek.Sunday, [FromRoute] int atHour = 0,
                                                                     [FromRoute] int atMinute        = 0, [FromRoute] int atSecond = 0)
        {
            model.Expression = CronTemplates.Weekly(dayOfWeek, atHour, atMinute, atSecond);

            return(await CreateBackgroundTask(model));
        }
Exemple #3
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);
        }