SHARE
TWEET

Untitled

a guest Sep 17th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top