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);
        }
        public async Task RunTest(Func <OperationContext, PrioritizedCopyScheduler, Task> func, PrioritizedCopySchedulerConfiguration prioritizedCopySchedulerConfiguration = null)
        {
            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 = (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();
            }
        }
        public async Task RunTest(Func <OperationContext, PrioritizedCopyScheduler, Task> func, PrioritizedCopySchedulerConfiguration prioritizedCopySchedulerConfiguration = null)
        {
            var(context, scheduler) = CreateContextAndScheduler(prioritizedCopySchedulerConfiguration);

            // 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(context, scheduler);
            }
            finally
            {
                // We do shut it down, so that any ongoing copies get cancelled
                await scheduler.ShutdownAsync(context).ShouldBeSuccess();
            }
        }