Пример #1
0
        public async void HeadersProvider()
        {
            var httpHandler = new MockHttpHandler();
            var responseHandler = new MockResponseHandler<object>();

            var headersProvider = new MockApiInstrumenter();
            headersProvider.Headers.Add(new HttpHeader("key", "value"));

            var endpoint = new HttpApiEndpoint("path/to/api", HttpMethod.Get, new Dictionary<string, IHttpArgumentHandler>(), responseHandler, Enumerable.Empty<HttpHeader>());
            await endpoint.Call(httpHandler, "http://localhost", new Dictionary<string, object>(), headersProvider.InstrumentCall);

            var header = httpHandler.Request.Headers.Single();
            Assert.AreEqual("key", header.Name);
            Assert.AreEqual("value", header.Values.Single());
        }
Пример #2
0
        public async Task HeadersProvider()
        {
            var httpHandler     = new MockHttpHandler();
            var responseHandler = new MockResponseHandler <object>();

            var headersProvider = new MockApiInstrumenter();

            headersProvider.Headers.Add(new HttpHeader("key", "value"));

            var endpoint = new HttpApiEndpoint(null, "path/to/api", HttpMethod.Get, new Dictionary <string, IHttpArgumentHandler>(), responseHandler, Enumerable.Empty <HttpHeader>());
            await endpoint.Call(httpHandler, "http://localhost", new Dictionary <string, object>(), headersProvider.InstrumentCall);

            var header = httpHandler.Request.Headers.Single();

            Assert.AreEqual("key", header.Name);
            Assert.AreEqual("value", header.Values.Single());
        }