public CorrelateMiddlewareTests(TestAppFactory <Startup> factory) { _options = new CorrelateOptions(); _mockHttp = new MockHttpHandler(); _rootFactory = factory; _rootFactory.LoggingEnabled = true; _factory = factory.WithWebHostBuilder(builder => builder .ConfigureTestServices(services => { services.AddTransient(_ => _mockHttp); services.AddSingleton <IOptions <CorrelateOptions> >(new OptionsWrapper <CorrelateOptions>(_options)); }) ); }
/// <summary> /// Initializes a new instance of the <see cref="CorrelateMiddleware"/> class. /// </summary> /// <param name="next">The next request delegate to invoke in the request execution pipeline.</param> /// <param name="options">The options.</param> /// <param name="logger">The logger.</param> /// <param name="correlationManager">The correlation manager.</param> public CorrelateMiddleware( RequestDelegate next, IOptions <CorrelateOptions> options, ILogger <CorrelateMiddleware> logger, CorrelationManager correlationManager) { _next = next ?? throw new ArgumentNullException(nameof(next)); _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _correlationManager = correlationManager ?? throw new ArgumentNullException(nameof(correlationManager)); if (_options.RequestHeaders == null || !_options.RequestHeaders.Any()) { _acceptedRequestHeaders = ImmutableArray <string> .Empty; } else { _acceptedRequestHeaders = _options.RequestHeaders.ToImmutableArray(); } }