Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. var uow = di.ServiceProvider.GetService<IUnitOfWork>();
  2. var hostedServices = di.ServiceProvider.GetServices<IHostedService>().ToList();
  3.  
  4. // Fail the test if we can't complete within the current ballpark benchmarks of 120 seconds per 500 customers
  5. var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(120 * (expectedTotal / 500)));
  6.  
  7. var importWorker = hostedServices.First(s => s is CustomerImportWorker);
  8. var importWorkerTask = Task.Run(() => importWorker.StartAsync(cancellationToken.Token), cancellationToken.Token);
  9.  
  10. var watchTask = Task.Run(async () =>
  11. {
  12. await WatchCustomerImportForCompletion(customerImportId, cancellationToken);
  13. }, cancellationToken.Token);
  14.  
  15. var loader = di.ServiceProvider.GetService<CustomerImportCsvLoader>();
  16.  
  17. await loader.LoadCustomersAsync(customerImportId,
  18. customerCsvFile
  19. );
  20.  
  21. customerImport = uow.CustomerImportOperations.OperationOfId(customerImportId);
  22.  
  23. Assert.NotNull(customerImport);
  24. Assert.Equal(expectedTotal, customerImport.TotalCustomers);
  25.  
  26. await Task.WhenAll(importWorkerTask, watchTask);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement