public async Task ItAllowsForRecurringTaskCrontabSchedulesToBeChanged() { var taskName = Guid.NewGuid().ToString(); Func <string, TaskScheduler, Task> configureSchedulerAction = async(semaphoreFile, taskScheduler) => { var crontab = $"*/{IntervalSeconds} * * * * *"; TaskSchedulerTestHelpers.SynchronizeToCrontabNextStart(crontab); Thread.Sleep(10); await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile), crontab, taskName); }; Func <string, TaskScheduler, Task> reconfigureRecurringTaskIntervalAction = async(semaphoreFile, taskScheduler) => { // Must synchronize to next start time or test becomes flaky var newCrontab = $"*/{IntervalSeconds*2} * * * * *"; TaskSchedulerTestHelpers.SynchronizeToCrontabNextStart(newCrontab); Thread.Sleep(10); await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile), newCrontab, taskName); }; await TaskSchedulerTestHelpers.AssertTaskSchedulerWritesSemaphoreTwiceAfterReconfiguringInterval( IntervalSeconds, configureSchedulerAction, reconfigureRecurringTaskIntervalAction); }
public async Task ItAllowsForRecurringTaskTimespanSchedulesToBeChanged() { var taskName = Guid.NewGuid().ToString(); Func <string, TaskScheduler, Task> configureSchedulerAction = async(semaphoreFile, taskScheduler) => { await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile), TimeSpan.FromSeconds(IntervalSeconds), taskName); }; Func <string, TaskScheduler, Task> reconfigureRecurringTaskIntervalAction = async(semaphoreFile, taskScheduler) => { await taskScheduler.AddRecurringTask(() => TaskQueueTestFixture.WriteSemaphore(semaphoreFile), TimeSpan.FromSeconds(IntervalSeconds * 2), taskName); }; await TaskSchedulerTestHelpers.AssertTaskSchedulerWritesSemaphoreTwiceAfterReconfiguringInterval( IntervalSeconds, configureSchedulerAction, reconfigureRecurringTaskIntervalAction); }