Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var uow = di.ServiceProvider.GetService<IUnitOfWork>();
- var hostedServices = di.ServiceProvider.GetServices<IHostedService>().ToList();
- // Fail the test if we can't complete within the current ballpark benchmarks of 120 seconds per 500 customers
- var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(120 * (expectedTotal / 500)));
- var importWorker = hostedServices.First(s => s is CustomerImportWorker);
- var importWorkerTask = Task.Run(() => importWorker.StartAsync(cancellationToken.Token), cancellationToken.Token);
- var watchTask = Task.Run(async () =>
- {
- await WatchCustomerImportForCompletion(customerImportId, cancellationToken);
- }, cancellationToken.Token);
- var loader = di.ServiceProvider.GetService<CustomerImportCsvLoader>();
- await loader.LoadCustomersAsync(customerImportId,
- customerCsvFile
- );
- customerImport = uow.CustomerImportOperations.OperationOfId(customerImportId);
- Assert.NotNull(customerImport);
- Assert.Equal(expectedTotal, customerImport.TotalCustomers);
- await Task.WhenAll(importWorkerTask, watchTask);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement