Beispiel #1
0
        public async Task LookupServiceAsync_FindsService_ReturnsURI()
        {
            IDiscoveryClient client = new TestDiscoveryClient(new TestServiceInstance(new Uri("https://foundit:5555")));
            var handler             = new DiscoveryHttpClientHandlerBase(client);
            var uri = new Uri("https://foo/test/bar/foo?test=1&test2=2");

            var result = await handler.LookupServiceAsync(uri);

            Assert.Equal(new Uri("https://foundit:5555/test/bar/foo?test=1&test2=2"), result);
        }
Beispiel #2
0
        public async Task LookupServiceAsync_DoesntFindService_ReturnsOriginalURI()
        {
            IDiscoveryClient client = new TestDiscoveryClient();
            var handler             = new DiscoveryHttpClientHandlerBase(client);
            var uri = new Uri("https://foo/test");

            var result = await handler.LookupServiceAsync(uri);

            Assert.Equal(uri, result);
        }
        public async Task LookupServiceAsync_NonDefaultPort_ReturnsOriginalURI()
        {
            // Arrange
            IDiscoveryClient client = new TestDiscoveryClient();
            var handler             = new DiscoveryHttpClientHandlerBase(client);
            var uri = new Uri("https://foo:8080/test");

            // Act and Assert
            var result = await handler.LookupServiceAsync(uri);

            Assert.Equal(uri, result);
        }
        public async void LookupServiceAsync_DoesntFindService_ReturnsOriginalURI()
        {
            // Arrange
            IDiscoveryClient client = new TestDiscoveryClient();
            DiscoveryHttpClientHandlerBase handler = new DiscoveryHttpClientHandlerBase(client);
            Uri uri = new Uri("https://foo/test");

            // Act and Assert
            var result = await handler.LookupServiceAsync(uri);

            Assert.Equal(uri, result);
        }
        public async void LookupServiceAsync_FindsService_ReturnsURI()
        {
            // Arrange
            IDiscoveryClient client = new TestDiscoveryClient(new TestServiceInstance(new Uri("http://foundit:5555")));
            DiscoveryHttpClientHandlerBase handler = new DiscoveryHttpClientHandlerBase(client);
            Uri uri = new Uri("http://foo/test/bar/foo?test=1&test2=2");

            // Act and Assert
            var result = await handler.LookupServiceAsync(uri);

            Assert.Equal(new Uri("http://foundit:5555/test/bar/foo?test=1&test2=2"), result);
        }
 public async Task <string> GetQuoteAsync()
 {
     return(await Policy <string>
            .Handle <Exception>()
            .FallbackAsync(_config.Value.FailedMessage)
            .WrapAsync(_apiCallPolicy)
            .ExecuteAsync(async() =>
     {
         var uri = await _discoveryClient.LookupServiceAsync(new Uri("http://FunnyQuotesLegacyService/FunnyQuoteserviceWCF.svc"));
         var wcfClient = new FunnyQuoteServiceClient(FunnyQuoteServiceClient.EndpointConfiguration.BasicHttpBinding_IFunnyQuoteService, uri.ToString());
         return await wcfClient.GetQuoteAsync();
     }));
 }
Beispiel #7
0
        /// <inheritdoc />
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var current = request.RequestUri;

            try
            {
                request.RequestUri = await _discoveryBase.LookupServiceAsync(current).ConfigureAwait(false);

                return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
            }
            catch (Exception e)
            {
                _logger?.LogDebug(e, "Exception during SendAsync()");
                throw;
            }
            finally
            {
                request.RequestUri = current;
            }
        }