public async Task RunTest(Func <OperationContext, PrioritizedCopyScheduler, Task> func) { var logger = TestGlobal.Logger; var context = new Context(logger); var operationContext = new OperationContext(context); var configuration = new CopySchedulerConfiguration() { Type = CopySchedulerType.Prioritized, PrioritizedCopySchedulerConfiguration = new PrioritizedCopySchedulerConfiguration(), }; var scheduler = (configuration.Create(context) as PrioritizedCopyScheduler) !; // NOTE: We do not startup the scheduler here in order to avoid launching the background task that // effectively schedules copies. This is done only for testing purposes. try { await func(operationContext, scheduler); } finally { // We do shut it down, so that any ongoing copies get cancelled await scheduler.ShutdownAsync(context).ShouldBeSuccess(); } }
private static (OperationContext context, PrioritizedCopyScheduler scheduler) CreateContextAndScheduler( PrioritizedCopySchedulerConfiguration prioritizedCopySchedulerConfiguration) { var logger = TestGlobal.Logger; var context = new Context(logger); var operationContext = new OperationContext(context); var configuration = new CopySchedulerConfiguration() { Type = CopySchedulerType.Prioritized, PrioritizedCopySchedulerConfiguration = prioritizedCopySchedulerConfiguration ?? new PrioritizedCopySchedulerConfiguration(), }; var scheduler = (PrioritizedCopyScheduler)configuration.Create(context); return(operationContext, scheduler); }