public HttpOutInterceptorTest()
        {
            _tracer      = new MockTracer();
            _options     = new HttpOutOptions();
            _interceptor = new HttpOutInterceptor(new NullLoggerFactory(), _tracer, Options.Create(_options));

            // Inner handler for mocking the result
            _httpHandler = new MockHttpMessageHandler();

            // Wrap with DiagnosticsHandler (which is internal :( )
            Type               type               = typeof(HttpClientHandler).Assembly.GetType("System.Net.Http.DiagnosticsHandler");
            ConstructorInfo    constructor        = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public)[0];
            HttpMessageHandler diagnosticsHandler = (HttpMessageHandler)constructor.Invoke(new object[] { _httpHandler });

            _httpClient = new HttpClient(diagnosticsHandler);

            _interceptor.Start();
        }
Ejemplo n.º 2
0
 public HttpOutInterceptor(ILoggerFactory loggerFactory, ITracer tracer, IOptions <HttpOutOptions> options)
     : base(loggerFactory, tracer)
 {
     _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
 }