public ProductsRepository(PurchaseOrdersDb dbContext, ILogger <ProductsRepository> logger) { _context = dbContext; _logger = logger; _retryPolicy = Policy .Handle <Exception>() .WaitAndRetryAsync( 5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (exception, timeSpan, context) => { var methodThatRaisedException = context["methodName"]; _logger.LogError("Exception in " + methodThatRaisedException + " " + exception + exception.StackTrace); }); }
private PurchaseOrdersDb GetInMemoryContextWithSeedData() { var options = new DbContextOptionsBuilder <PurchaseOrdersDb>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new PurchaseOrdersDb(options); context.PurchaseStatus.Add(_stubPurchaseStatusDto); context.PaymentInformation.Add(_stubPaymentInformationDto); context.PurchaseOrders.Add(_stubPurchaseOrderDto); context.SaveChanges(); return(context); }