public FluentMiddlewareHttpHandler(
     IFluentHttpMiddlewareRunner middlewareRunner,
     FluentHttpClient httpClient,
     RequestTracker requestTracker,
     HttpMessageHandler messageHandler = null
     ) : base(messageHandler ?? new HttpClientHandler())
 {
     _middlewareRunner = middlewareRunner;
     _httpClient       = httpClient;
     _requestTracker   = requestTracker;
 }
        public async Task WithListener_WhenListener_ShouldUseListener()
        {
            var httpClientTester = new HttpClientTester()
                                   .SetResponseContent(new Person("James"));

            var listener = new MessageListener();
            var client   = new FluentHttpClient("Test", httpClientTester.Client, listener);
            var response = await client
                           .Get("url")
                           .ExecuteAsync <Person>();

            response?.StatusCode.Should().Be(200);
            listener.RequestMessage.Should().NotBeNull();
            listener.ResponseMessage.Should().NotBeNull();
        }
Beispiel #3
0
        public void ShouldCreateFluentRequest()
        {
            var http              = new HttpClient();
            var client            = new FluentHttpClient(http, null);
            var source            = new CancellationTokenSource();
            var cancellationToken = source.Token;
            var url     = new Uri("https://unused.uri");
            var request = client.PerformRequestAsync(HttpMethod.Get, url, cancellationToken);

            Assert.NotNull(request);
            //Assert.NotNull(request.BaseClient);
            //Assert.Same(http, request.BaseClient);
            Assert.NotNull(request.BaseRequest);
            Assert.Same(HttpMethod.Get, request.BaseRequest.Method);
            Assert.Same(url, request.BaseRequest.RequestUri);
            Assert.NotNull(request.CancellationToken);
        }
Beispiel #4
0
 public static RequestBuilder Get(this FluentHttpClient client, string uri)
 {
     return(new RequestBuilder(client, uri, HttpMethod.Get));
 }
Beispiel #5
0
 public RequestBuilder(FluentHttpClient client, string uri, HttpMethod httpMethod)
 {
     _client     = client ?? throw new ArgumentNullException(nameof(client));
     _uri        = uri;
     _httpMethod = httpMethod;
 }