public ExceptionHandlerTests(ExampleIntegrationTestContext <TestableStartup <ErrorDbContext>, ErrorDbContext> testContext) { _testContext = testContext; testContext.UseController <ThrowingArticlesController>(); testContext.UseController <ConsumerArticlesController>(); FakeLoggerFactory loggerFactory = null; testContext.ConfigureLogging(options => { loggerFactory = new FakeLoggerFactory(); options.ClearProviders(); options.AddProvider(loggerFactory); options.SetMinimumLevel(LogLevel.Warning); }); testContext.ConfigureServicesBeforeStartup(services => { if (loggerFactory != null) { services.AddSingleton(_ => loggerFactory); } }); testContext.ConfigureServicesAfterStartup(services => { services.AddResourceService <ConsumerArticleService>(); services.AddScoped <IExceptionHandler, AlternateExceptionHandler>(); }); }
public LoggingTests(ExampleIntegrationTestContext <TestableStartup <AuditDbContext>, AuditDbContext> testContext) { _testContext = testContext; testContext.UseController <AuditEntriesController>(); FakeLoggerFactory loggerFactory = null; testContext.ConfigureLogging(options => { loggerFactory = new FakeLoggerFactory(); options.ClearProviders(); options.AddProvider(loggerFactory); options.SetMinimumLevel(LogLevel.Trace); options.AddFilter((_, __) => true); }); testContext.ConfigureServicesBeforeStartup(services => { if (loggerFactory != null) { services.AddSingleton(_ => loggerFactory); } }); }