public void GivenACompaniesHouseAuthorizationHandler()
        {
            var innerHandler = new Mock <HttpMessageHandler>(MockBehavior.Strict);

            innerHandler.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .Callback((HttpRequestMessage r, CancellationToken c) => _actual = r)
            .ReturnsAsync(new HttpResponseMessage());

            _apiKey  = "42c8154e-982d-4a62-913d-89aafb320dbc";
            _handler = new CompaniesHouseAuthorizationHandler(_apiKey)
            {
                InnerHandler = innerHandler.Object
            };
        }
Exemplo n.º 2
0
        public HttpClient CreateHttpClient()
        {
            var companiesHouseAuthorizationHandler = new CompaniesHouseAuthorizationHandler(_settings.ApiKey)
            {
                InnerHandler = _settings.HttpMessageHandlerCreator()
            };

            var httpClient = new HttpClient(companiesHouseAuthorizationHandler)
            {
                BaseAddress = _settings.BaseUri
            };


            return(httpClient);
        }
Exemplo n.º 3
0
        public HttpClient CreateHttpClient()
        {
            var httpClientHandler = new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            };

            var companiesHouseAuthorizationHandler = new CompaniesHouseAuthorizationHandler(_settings.ApiKey)
            {
                InnerHandler = httpClientHandler
            };

            var httpClient = new HttpClient(companiesHouseAuthorizationHandler)
            {
                BaseAddress = _settings.BaseUri
            };


            return(httpClient);
        }