public async Task aggregate_tests(string method, string baseAddress, string requestUri, string absoluteUri, string exceptionMessage)
        {
            _method           = method;
            _absoluteUri      = absoluteUri;
            _exceptionMessage = exceptionMessage;

            var configuration = new InstrumentingConfiguration {
                Uri = new Uri(baseAddress), TimeoutMs = 3000
            };

            using (var baseHttpClient = new DefaultHttpClient(configuration))
            {
                var httpClient = baseHttpClient.AddInstrumenting(configuration, new[] { _callback });
                var message    = new HttpRequestMessage(new HttpMethod(method), requestUri);

                try
                {
                    await httpClient.SendAsync(message);
                }
                catch (Exception e)
                {
                    _requestException = e;
                }
            }

            // TODO: bit nasty
            should_throw_http_client_connection_exception();
            should_populate_http_client_exception_message();
            should_populate_http_client_exception_request_id();
            should_not_log_exception_thrown();
            should_log_server_unavailable();
        }
Example #2
0
        public static DisposableHttpClient CreateClientWithTagging(this StubHttpApi api, ISessionIdAccessor sessionIdAccessor, ICorrelationIdAccessor correlationIdAccessor, IOutboundRequestIdAccessor outboundRequestIdAccessor, IGenerateGuids guidGenerator, IApplicationInfo applicationInfo, int timeoutMs = 3000)
        {
            var configuration = new InstrumentingConfiguration {
                Uri = api.BaseUri, TimeoutMs = timeoutMs
            };
            var httpClient = new DefaultHttpClient(configuration);

            return(new DisposableHttpClient(httpClient, httpClient.AddTagging(sessionIdAccessor, correlationIdAccessor, outboundRequestIdAccessor, guidGenerator, applicationInfo)));
        }
Example #3
0
        public static DisposableHttpClient CreateClientWithInstrumenting(this StubHttpApi api, IHttpClientEventCallback callback, int timeoutMs = 3000)
        {
            var configuration = new InstrumentingConfiguration {
                Uri = api.BaseUri, TimeoutMs = timeoutMs
            };
            var httpClient = new DefaultHttpClient(configuration);

            return(new DisposableHttpClient(httpClient, httpClient.AddInstrumenting(configuration, new [] { callback })));
        }
Example #4
0
        public async Task setup_scenario()
        {
            var baseHttpClient = new StubHttpClient(new Exception());
            var configuration  = new InstrumentingConfiguration {
                Uri = new Uri("http://localhost")
            };
            var httpClient = baseHttpClient.AddInstrumenting(configuration, new[] { _callback });

            try
            {
                await httpClient.GetAsync("/ping");
            }
            catch
            {
                // Ignore the exception
            }
        }
Example #5
0
        public async Task  setup_scenario()
        {
            _exceptionThrown = new Exception();
            var baseHttpClient = new StubHttpClient(_exceptionThrown);
            var configuration  = new InstrumentingConfiguration {
                Uri = new Uri("http://exception-host")
            };
            var httpClient = baseHttpClient.AddInstrumenting(configuration, new [] { _callback });

            try
            {
                await httpClient.GetAsync("/ping");
            }
            catch (Exception e)
            {
                _exception = e;
            }
        }