コード例 #1
0
        public async Task ResolvesUri_TracksStats_WithProvidedLoadBalancer()
        {
            var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "https://replaceme/api");
            var loadBalancer       = new FakeLoadBalancer();
            var handler            = new LoadBalancerDelegatingHandler(loadBalancer)
            {
                InnerHandler = new TestInnerDelegatingHandler()
            };
            var invoker = new HttpMessageInvoker(handler);

            var result = await invoker.SendAsync(httpRequestMessage, default);

            Assert.Equal("https://someresolvedhost/api", result.Headers.GetValues("requestUri").First());
            Assert.Single(loadBalancer.Stats);
        }
コード例 #2
0
        public async Task TracksStats_WhenRequestsGoWrong_WithProvidedLoadBalancer()
        {
            // arrange
            var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "https://replaceme/api");
            var loadBalancer       = new FakeLoadBalancer();
            var handler            = new LoadBalancerDelegatingHandler(loadBalancer)
            {
                InnerHandler = new TestInnerDelegatingHandlerBrokenServer()
            };
            var invoker = new HttpMessageInvoker(handler);

            // act
            var result = await invoker.SendAsync(httpRequestMessage, default);

            // assert
            Assert.Single(loadBalancer.Stats);
            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
            Assert.Equal("https://someresolvedhost/api", result.Headers.GetValues("requestUri").First());
        }