Example #1
0
        public async Task ItExecutesARecurringTaskAtTheSpecifiedInterval()
        {
            Func <string, TaskScheduler, Task> configureSchedulerAction = async(semaphoreFile, taskScheduler) =>
            {
                await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile),
                                                     TimeSpan.FromSeconds(IntervalSeconds), RandomTaskName);
            };

            await TaskSchedulerTestHelpers.AssertTaskSchedulerWritesSemaphoreTwice(
                IntervalSeconds,
                configureSchedulerAction);
        }
Example #2
0
        public async Task ItExecutesARecurringTaskAtTheSpecifiedCrontabInterval()
        {
            Func <string, TaskScheduler, Task> configureSchedulerAction = async(semaphoreFile, taskScheduler) =>
            {
                var crontab = $"*/{IntervalSeconds} * * * * *";
                TaskSchedulerTestHelpers.SynchronizeToCrontabNextStart(crontab);
                Thread.Sleep(10);

                await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile),
                                                     crontab, RandomTaskName);
            };

            await TaskSchedulerTestHelpers.AssertTaskSchedulerWritesSemaphoreTwice(IntervalSeconds,
                                                                                   configureSchedulerAction);
        }