public void should_cache_two_http_client_different_re_route()
        {
            var configuration = new FileConfiguration
            {
                ReRoutes = new List <FileReRoute>
                {
                    new FileReRoute
                    {
                        DownstreamPathTemplate = "/",
                        DownstreamScheme       = "http",
                        DownstreamHostAndPorts = new List <FileHostAndPort>
                        {
                            new FileHostAndPort
                            {
                                Host = "localhost",
                                Port = 58817,
                            }
                        },
                        UpstreamPathTemplate = "/",
                        UpstreamHttpMethod   = new List <string> {
                            "Get"
                        },
                    },
                    new FileReRoute
                    {
                        DownstreamPathTemplate = "/two",
                        DownstreamScheme       = "http",
                        DownstreamHostAndPorts = new List <FileHostAndPort>
                        {
                            new FileHostAndPort
                            {
                                Host = "localhost",
                                Port = 58817,
                            }
                        },
                        UpstreamPathTemplate = "/two",
                        UpstreamHttpMethod   = new List <string> {
                            "Get"
                        },
                    }
                }
            };

            var cache = new FakeHttpClientCache();

            this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:58817", 200, "Hello from Laura"))
            .And(x => _steps.GivenThereIsAConfiguration(configuration))
            .And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/two"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/two"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/two"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
            .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
            .And(x => cache.Count.ShouldBe(2))
            .BDDfy();
        }
Beispiel #2
0
        public void should_cache_one_http_client_same_re_route()
        {
            var port = RandomPortFinder.GetRandomPort();

            var configuration = new FileConfiguration
            {
                Routes = new List <FileRoute>
                {
                    new FileRoute
                    {
                        DownstreamPathTemplate = "/",
                        DownstreamScheme       = "http",
                        DownstreamHostAndPorts = new List <FileHostAndPort>
                        {
                            new FileHostAndPort
                            {
                                Host = "localhost",
                                Port = port,
                            }
                        },
                        UpstreamPathTemplate = "/",
                        UpstreamHttpMethod   = new List <string> {
                            "Get"
                        },
                    }
                }
            };

            var cache = new FakeHttpClientCache();

            this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", 200, "Hello from Laura"))
            .And(x => _steps.GivenThereIsAConfiguration(configuration))
            .And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
            .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
            .And(x => ThenTheCountShouldBe(cache, 1))
            .BDDfy();
        }
Beispiel #3
0
 private void ThenTheCountShouldBe(FakeHttpClientCache cache, int count)
 {
     cache.Count.ShouldBe(count);
 }