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();
        }
示例#2
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 })));
        }