예제 #1
0
        private static async Task <FakeLogger> ExecuteFakeRequest(HttpMessageParts?verbosity = null)
        {
            var logger = new FakeLogger();

            var httpClientHandler = new HttpClientHandler();

            httpClientHandler.UseCookies = true;
            httpClientHandler.CookieContainer.Add(new Cookie(CookieName, CookieValue, "", new Uri(_testUri).Host));

            var builder = new HttpHandlerBuilder(new FakeHttpTraceHandler(httpClientHandler, logger));

            builder.AddHandler(new FakeHandler())
            .AddHandler(new SillyHandler())
            .AddHandler(new FakeHandler());

            if (verbosity != null)
            {
                builder.SetHttpTracerVerbosity(verbosity.Value);
            }

            var client = new HttpClient(builder.Build());
            await client.GetAsync(_testUri);

            return(logger);
        }
예제 #2
0
        private static async Task <FakeLogger> ExecuteFakeRequest(HttpMessageParts?verbosity = null, JsonFormatting jsonFormatting = JsonFormatting.None, string responseContent = FakeHttpTraceHandler.FakeResponseContent)
        {
            var logger = new FakeLogger();

            var httpClientHandler = new HttpClientHandler();

            httpClientHandler.UseCookies = true;
            httpClientHandler.CookieContainer.Add(new Cookie(CookieName, CookieValue, "", new Uri(TestUri).Host));

            HttpContent fakeContent = new StringContent("{\"Foo\": \"Bar\"}", Encoding.Default, "application/json");
            var         builder     = new HttpHandlerBuilder(new FakeHttpTraceHandler(httpClientHandler, logger)
            {
                ResponseContent = responseContent,
                JsonFormatting  = jsonFormatting
            });

            builder.AddHandler(new FakeHandler())
            .AddHandler(new SillyHandler())
            .AddHandler(new FakeHandler());

            if (verbosity != null)
            {
                builder.SetHttpTracerVerbosity(verbosity.Value);
            }

            var client = new HttpClient(builder.Build());
            await client.PostAsync(TestUri, fakeContent);

            return(logger);
        }
예제 #3
0
        private static async Task <FakeLogger> ExecuteFakeRequest(HttpMessageParts?verbosity = null)
        {
            var logger  = new FakeLogger();
            var builder = new HttpHandlerBuilder(new FakeHttpTraceHandler(logger));

            builder.AddHandler(new FakeHandler())
            .AddHandler(new SillyHandler())
            .AddHandler(new FakeHandler());

            if (verbosity != null)
            {
                builder.SetHttpTracerVerbosity(verbosity.Value);
            }

            var client = new HttpClient(builder.Build());
            await client.GetAsync(_testUri);

            return(logger);
        }