private async Task <CoreTestContext> ExecuteOrchestrator( int jobsterCount, int batchSize, bool jobsterThrowsExceptionInTheMiddle = false, ExceptionPolicy exceptionPolicy = ExceptionPolicy.NoThrow, CoreTestContext context = null, IEnumerable <IJobsterAsync <CoreTestContext> > state = null, MemoryJobsterStateHandler <CoreTestContext> stateHandler = null, IProgressNotifier <CoreTestContext> progressNotifier = null) { context ??= new CoreTestContext(); int middleJobster = jobsterCount / 2; IList <IJobsterAsync <CoreTestContext> > jobsters = new List <IJobsterAsync <CoreTestContext> >(jobsterCount); for (int i = 0; i < jobsterCount; i++) { jobsters.Add(new TestJobster( context, jobsterThrowsExceptionInTheMiddle && i == middleJobster)); } JobsterBuilder <CoreTestContext> builder = new JobsterBuilder <CoreTestContext>(_mockLogger) .AddBatchSize(batchSize) .AddExceptionPolicy(exceptionPolicy) .AddJobsters(jobsters.ToArray()) .AddStateHandler(stateHandler ?? new MemoryJobsterStateHandler <CoreTestContext>( state ?? new IJobsterAsync <CoreTestContext> [0])); if (progressNotifier != null) { builder.AddProgressNotifier(progressNotifier); } _ = await builder .BuildEngine() .ScheduleJobstersAsync(_cancellationTokenSource.Token); return(context); }
public void Configuration_BasicConfiguration_ShouldLetAddProgressNotifier() { Assert.DoesNotThrow(() => _jobsterBuilder.AddProgressNotifier(new LocalEventProgressNotifier <CoreTestContext>())); }