Beispiel #1
0
        public void should_create_downstream_route_with_rate_limit_options()
        {
            var rateLimitOptions = new RateLimitOptionsBuilder()
                                   .WithEnableRateLimiting(true)
                                   .WithClientIdHeader("test")
                                   .Build();

            var downstreamReRoute = new DownstreamReRouteBuilder()
                                    .WithServiceName("auth")
                                    .WithRateLimitOptions(rateLimitOptions)
                                    .Build();

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamReRoute(downstreamReRoute)
                          .Build();

            var reRoutes = new List <ReRoute> {
                reRoute
            };

            var configuration = new InternalConfiguration(reRoutes, "doesnt matter", null, "doesnt matter", _loadBalancerOptions, "http", _qoSOptions, _handlerOptions);

            this.Given(_ => GivenTheConfiguration(configuration))
            .When(_ => WhenICreate())
            .Then(_ => ThenTheDownstreamRouteIsCreated())
            .And(_ => WithRateLimitOptions(rateLimitOptions))
            .BDDfy();
        }
Beispiel #2
0
        private ReRoute SetUpAggregateReRoute(IEnumerable <ReRoute> reRoutes, FileAggregateReRoute aggregateReRoute, FileGlobalConfiguration globalConfiguration)
        {
            var applicableReRoutes = new List <DownstreamReRoute>();
            var allReRoutes        = reRoutes.SelectMany(x => x.DownstreamReRoute);

            foreach (var reRouteKey in aggregateReRoute.ReRouteKeys)
            {
                var selec = allReRoutes.FirstOrDefault(q => q.Key == reRouteKey);
                if (selec == null)
                {
                    return(null);
                }

                applicableReRoutes.Add(selec);
            }

            var upstreamTemplatePattern = _creator.Create(aggregateReRoute);

            var reRoute = new ReRouteBuilder()
                          .WithUpstreamHttpMethod(aggregateReRoute.UpstreamHttpMethod)
                          .WithUpstreamPathTemplate(upstreamTemplatePattern)
                          .WithDownstreamReRoutes(applicableReRoutes)
                          .WithAggregateReRouteConfig(aggregateReRoute.ReRouteKeysConfig)
                          .WithUpstreamHost(aggregateReRoute.UpstreamHost)
                          .WithAggregator(aggregateReRoute.Aggregator)
                          .Build();

            return(reRoute);
        }
        public ReRoute SetUpAggregateReRoute(List <ReRoute> reRoutes, FileAggregateReRoute aggregateReRoute, FileGlobalConfiguration globalConfiguration)
        {
            var applicableReRoutes = reRoutes
                                     .SelectMany(x => x.DownstreamReRoute)
                                     .Where(r => aggregateReRoute.ReRouteKeys.Contains(r.Key))
                                     .ToList();

            if (applicableReRoutes.Count != aggregateReRoute.ReRouteKeys.Count)
            {
                //todo - log or throw or return error whatever?
            }

            //make another re route out of these
            var upstreamTemplatePattern = _upstreamTemplatePatternCreator.Create(aggregateReRoute);

            var reRoute = new ReRouteBuilder()
                          .WithUpstreamPathTemplate(aggregateReRoute.UpstreamPathTemplate)
                          .WithUpstreamHttpMethod(aggregateReRoute.UpstreamHttpMethod)
                          .WithUpstreamTemplatePattern(upstreamTemplatePattern)
                          .WithDownstreamReRoutes(applicableReRoutes)
                          .WithUpstreamHost(aggregateReRoute.UpstreamHost)
                          .WithAggregator(aggregateReRoute.Aggregator)
                          .Build();

            return(reRoute);
        }
        public void should_not_find_aggregator()
        {
            var reRoute = new ReRouteBuilder().Build();

            var context = new DownstreamContext(new DefaultHttpContext());

            var contexts = new List <DownstreamContext>
            {
                new DownstreamContext(new DefaultHttpContext())
                {
                    DownstreamResponse = new DownstreamResponse(new StringContent("Tom"), HttpStatusCode.OK, new List <KeyValuePair <string, IEnumerable <string> > >(), "some reason")
                },
                new DownstreamContext(new DefaultHttpContext())
                {
                    DownstreamResponse = new DownstreamResponse(new StringContent("Laura"), HttpStatusCode.OK, new List <KeyValuePair <string, IEnumerable <string> > >(), "some reason")
                }
            };

            this.Given(_ => GivenTheProviderReturnsError())
            .And(_ => GivenReRoute(reRoute))
            .And(_ => GivenContexts(contexts))
            .And(_ => GivenContext(context))
            .When(_ => WhenIAggregate())
            .Then(_ => ThenTheProviderIsCalled())
            .And(_ => ThenTheErrorIsReturned())
            .BDDfy();
        }
        public void should_call_middleware_and_ratelimiting()
        {
            var upstreamTemplate = new UpstreamPathTemplateBuilder().Build();

            var downstreamReRoute = new DownstreamReRouteBuilder()
                                    .WithEnableRateLimiting(true)
                                    .WithRateLimitOptions(new RateLimitOptions(true, "ClientId", () => new List <string>(), false, "", "", new RateLimitRule("1s", 100, 3), 429))
                                    .WithUpstreamHttpMethod(new List <string> {
                "Get"
            })
                                    .WithUpstreamPathTemplate(upstreamTemplate)
                                    .Build();

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamReRoute(downstreamReRoute)
                          .WithUpstreamHttpMethod(new List <string> {
                "Get"
            })
                          .Build();

            var downstreamRoute = new DownstreamRoute(new List <Ocelot.DownstreamRouteFinder.UrlMatcher.PlaceholderNameAndValue>(), reRoute);

            this.Given(x => x.GivenTheDownStreamRouteIs(downstreamRoute))
            .When(x => x.WhenICallTheMiddlewareMultipleTime(2))
            .Then(x => x.ThenresponseStatusCodeIs200())
            .When(x => x.WhenICallTheMiddlewareMultipleTime(3))
            .Then(x => x.ThenresponseStatusCodeIs429())
            .BDDfy();
        }
Beispiel #6
0
        public void should_return_error_if_no_qos_provider_with_key()
        {
            var reRoute = new ReRouteBuilder().Build();

            this.When(x => x.WhenWeGetTheQoSProvider(reRoute))
            .Then(x => x.ThenAnErrorIsReturned())
            .BDDfy();
        }
Beispiel #7
0
        public void should_store_load_balancer_on_first_request()
        {
            var reRoute = new ReRouteBuilder().WithReRouteKey("test").Build();

            this.Given(x => x.GivenThereIsALoadBalancer(reRoute, new FakeLoadBalancer()))
            .Then(x => x.ThenItIsAdded())
            .BDDfy();
        }
Beispiel #8
0
        public void should_store_qos_provider_on_first_request()
        {
            var reRoute = new ReRouteBuilder().WithReRouteKey("test").Build();

            this.Given(x => x.GivenThereIsAQoSProvider(reRoute, new FakeQoSProvider()))
            .Then(x => x.ThenItIsAdded())
            .BDDfy();
        }
Beispiel #9
0
        public void should_return_error_if_exception()
        {
            var reRoute = new ReRouteBuilder().Build();

            this.When(x => x.WhenWeGetTheLoadBalancer(reRoute))
            .Then(x => x.ThenAnErrorIsReturned())
            .BDDfy();
        }
Beispiel #10
0
        private async Task <ReRoute> SetUpReRoute(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
        {
            var fileReRouteOptions = _fileReRouteOptionsCreator.Create(fileReRoute);

            var requestIdKey = _requestIdKeyCreator.Create(fileReRoute, globalConfiguration);

            var reRouteKey = CreateReRouteKey(fileReRoute);

            var upstreamTemplatePattern = _upstreamTemplatePatternCreator.Create(fileReRoute);

            var serviceProviderConfiguration = _serviceProviderConfigCreator.Create(fileReRoute, globalConfiguration);

            var authOptionsForRoute = _authOptionsCreator.Create(fileReRoute);

            var claimsToHeaders = _claimsToThingCreator.Create(fileReRoute.AddHeadersToRequest);

            var claimsToClaims = _claimsToThingCreator.Create(fileReRoute.AddClaimsToRequest);

            var claimsToQueries = _claimsToThingCreator.Create(fileReRoute.AddQueriesToRequest);

            var qosOptions = _qosOptionsCreator.Create(fileReRoute);

            var rateLimitOption = _rateLimitOptionsCreator.Create(fileReRoute, globalConfiguration, fileReRouteOptions.EnableRateLimiting);

            var region = _regionCreator.Create(fileReRoute);

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamPathTemplate(fileReRoute.DownstreamPathTemplate)
                          .WithUpstreamPathTemplate(fileReRoute.UpstreamPathTemplate)
                          .WithUpstreamHttpMethod(fileReRoute.UpstreamHttpMethod)
                          .WithUpstreamTemplatePattern(upstreamTemplatePattern)
                          .WithIsAuthenticated(fileReRouteOptions.IsAuthenticated)
                          .WithAuthenticationOptions(authOptionsForRoute)
                          .WithClaimsToHeaders(claimsToHeaders)
                          .WithClaimsToClaims(claimsToClaims)
                          .WithRouteClaimsRequirement(fileReRoute.RouteClaimsRequirement)
                          .WithIsAuthorised(fileReRouteOptions.IsAuthorised)
                          .WithClaimsToQueries(claimsToQueries)
                          .WithRequestIdKey(requestIdKey)
                          .WithIsCached(fileReRouteOptions.IsCached)
                          .WithCacheOptions(new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds, region))
                          .WithDownstreamScheme(fileReRoute.DownstreamScheme)
                          .WithLoadBalancer(fileReRoute.LoadBalancer)
                          .WithDownstreamHost(fileReRoute.DownstreamHost)
                          .WithDownstreamPort(fileReRoute.DownstreamPort)
                          .WithLoadBalancerKey(reRouteKey)
                          .WithServiceProviderConfiguraion(serviceProviderConfiguration)
                          .WithIsQos(fileReRouteOptions.IsQos)
                          .WithQosOptions(qosOptions)
                          .WithEnableRateLimiting(fileReRouteOptions.EnableRateLimiting)
                          .WithRateLimitOptions(rateLimitOption)
                          .Build();

            await SetupLoadBalancer(reRoute);

            SetupQosProvider(reRoute);
            return(reRoute);
        }
Beispiel #11
0
        public void should_not_store_load_balancer_on_second_request()
        {
            var reRoute = new ReRouteBuilder().WithLoadBalancer("FakeLoadBalancer").WithReRouteKey("test").Build();

            this.Given(x => x.GivenThereIsALoadBalancer(reRoute, new FakeLoadBalancer()))
            .When(x => x.WhenWeGetTheLoadBalancer(reRoute))
            .Then(x => x.ThenItIsReturned())
            .BDDfy();
        }
        private void GivenTheReRouteHasPreFindAndReplaceSetUp()
        {
            var fAndRs   = new List <HeaderFindAndReplace>();
            var reRoute  = new ReRouteBuilder().WithUpstreamHeaderFindAndReplace(fAndRs).WithDownstreamHeaderFindAndReplace(fAndRs).Build();
            var dR       = new DownstreamRoute(null, reRoute);
            var response = new OkResponse <DownstreamRoute>(dR);

            ScopedRepository.Setup(x => x.Get <DownstreamRoute>("DownstreamRoute")).Returns(response);
        }
Beispiel #13
0
        public void should_not_multiplex()
        {
            var reRoute = new ReRouteBuilder().WithDownstreamReRoute(new DownstreamReRouteBuilder().Build()).Build();

            this.Given(x => GivenTheFollowing(reRoute))
            .When(x => WhenIMultiplex())
            .Then(x => ThePipelineIsCalled(1))
            .BDDfy();
        }
Beispiel #14
0
        private void GivenTheDownstreamRouteIs()
        {
            var reRoute         = new ReRouteBuilder().WithIsCached(true).WithCacheOptions(new CacheOptions(100)).Build();
            var downstreamRoute = new DownstreamRoute(new List <UrlPathPlaceholderNameAndValue>(), reRoute);

            _scopedRepo
            .Setup(x => x.Get <DownstreamRoute>(It.IsAny <string>()))
            .Returns(new OkResponse <DownstreamRoute>(downstreamRoute));
        }
Beispiel #15
0
        public void should_return_simple_json_aggregator()
        {
            var reRoute = new ReRouteBuilder()
                          .Build();

            this.Given(_ => GivenReRoute(reRoute))
            .When(_ => WhenIGet())
            .Then(_ => ThenTheAggregatorIs <SimpleJsonResponseAggregator>())
            .BDDfy();
        }
Beispiel #16
0
        public void should_aggregate_n_responses_and_set_response_content_on_upstream_context_withConfig()
        {
            var commentsDownstreamReRoute = new DownstreamReRouteBuilder().WithKey("Comments").Build();

            var userDetailsDownstreamReRoute = new DownstreamReRouteBuilder().WithKey("UserDetails")
                                               .WithUpstreamPathTemplate(new UpstreamPathTemplate("", 0, false, "/v1/users/{userId}"))
                                               .Build();

            var downstreamReRoutes = new List <DownstreamReRoute>
            {
                commentsDownstreamReRoute,
                userDetailsDownstreamReRoute
            };

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamReRoutes(downstreamReRoutes)
                          .WithAggregateReRouteConfig(new List <AggregateReRouteConfig>()
            {
                new AggregateReRouteConfig()
                {
                    ReRouteKey = "UserDetails", JsonPath = "$[*].writerId", Parameter = "userId"
                }
            })
                          .Build();

            var commentsResponseContent   = @"[{""id"":1,""writerId"":1,""postId"":1,""text"":""text1""},{""id"":2,""writerId"":2,""postId"":2,""text"":""text2""},{""id"":3,""writerId"":2,""postId"":1,""text"":""text21""}]";
            var commentsDownstreamContext = new DownstreamContext(new DefaultHttpContext())
            {
                DownstreamResponse = new DownstreamResponse(new StringContent(commentsResponseContent, Encoding.UTF8, "application/json"), HttpStatusCode.OK, new EditableList <KeyValuePair <string, IEnumerable <string> > >(), "some reason"),
                DownstreamReRoute  = commentsDownstreamReRoute
            };

            var userDetailsResponseContent   = @"[{""id"":1,""firstName"":""abolfazl"",""lastName"":""rajabpour""},{""id"":2,""firstName"":""reza"",""lastName"":""rezaei""}]";
            var userDetailsDownstreamContext = new DownstreamContext(new DefaultHttpContext())
            {
                DownstreamResponse = new DownstreamResponse(new StringContent(userDetailsResponseContent, Encoding.UTF8, "application/json"), HttpStatusCode.OK, new List <KeyValuePair <string, IEnumerable <string> > >(), "some reason"),
                DownstreamReRoute  = userDetailsDownstreamReRoute
            };

            var downstreamContexts = new List <DownstreamContext> {
                commentsDownstreamContext, userDetailsDownstreamContext
            };

            var expected = "{\"Comments\":" + commentsResponseContent + ",\"UserDetails\":" + userDetailsResponseContent + "}";

            this.Given(x => GivenTheUpstreamContext(new DownstreamContext(new DefaultHttpContext())))
            .And(x => GivenTheReRoute(reRoute))
            .And(x => GivenTheDownstreamContext(downstreamContexts))
            .When(x => WhenIAggregate())
            .Then(x => ThenTheContentIs(expected))
            .And(x => ThenTheContentTypeIs("application/json"))
            .And(x => ThenTheReasonPhraseIs("cannot return from aggregate..which reason phrase would you use?"))
            .BDDfy();
        }
Beispiel #17
0
        public void should_return_user_defined_aggregator()
        {
            var reRoute = new ReRouteBuilder()
                          .WithAggregator("doesntmatter")
                          .Build();

            this.Given(_ => GivenReRoute(reRoute))
            .When(_ => WhenIGet())
            .Then(_ => ThenTheAggregatorIs <UserDefinedResponseAggregator>())
            .BDDfy();
        }
Beispiel #18
0
        public void should_return_error_if_any_downstreams_have_errored()
        {
            var billDownstreamReRoute = new DownstreamReRouteBuilder().WithKey("Bill").Build();

            var georgeDownstreamReRoute = new DownstreamReRouteBuilder().WithKey("George").Build();

            var downstreamReRoutes = new List <DownstreamReRoute>
            {
                billDownstreamReRoute,
                georgeDownstreamReRoute
            };

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamReRoutes(downstreamReRoutes)
                          .Build();

            var billDownstreamContext = new DownstreamContext(new DefaultHttpContext())
            {
                DownstreamResponse =
                    new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent("Bill says hi")
                },
                DownstreamReRoute = billDownstreamReRoute
            };

            var georgeDownstreamContext = new DownstreamContext(new DefaultHttpContext())
            {
                DownstreamResponse =
                    new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent("Error")
                },
                DownstreamReRoute = georgeDownstreamReRoute,
                Errors            = new List <Error>()
                {
                    new AnyError()
                }
            };

            var downstreamContexts = new List <DownstreamContext> {
                billDownstreamContext, georgeDownstreamContext
            };

            var expected = "Error";

            this.Given(x => GivenTheUpstreamContext(new DownstreamContext(new DefaultHttpContext())))
            .And(x => GivenTheReRoute(reRoute))
            .And(x => GivenTheDownstreamContext(downstreamContexts))
            .When(x => WhenIAggregate())
            .Then(x => ThenTheContentIs(expected))
            .And(x => ThenTheErrorIsMapped())
            .BDDfy();
        }
        public void should_return_no_load_balancer()
        {
            var reRoute = new ReRouteBuilder()
                          .Build();

            this.Given(x => x.GivenAReRoute(reRoute))
            .And(x => x.GivenTheServiceProviderFactoryReturns())
            .When(x => x.WhenIGetTheLoadBalancer())
            .Then(x => x.ThenTheLoadBalancerIsReturned <NoLoadBalancer>())
            .BDDfy();
        }
Beispiel #20
0
        public void should_return_no_qos_provider()
        {
            var reRoute = new ReRouteBuilder()
                          .WithUpstreamHttpMethod("get")
                          .WithIsQos(false)
                          .Build();

            this.Given(x => x.GivenAReRoute(reRoute))
            .When(x => x.WhenIGetTheQoSProvider())
            .Then(x => x.ThenTheQoSProviderIsReturned <NoQoSProvider>())
            .BDDfy();
        }
        public void should_return_no_service_provider()
        {
            var serviceConfig = new ServiceProviderConfigurationBuilder()
                                .Build();

            var reRoute = new ReRouteBuilder().Build();

            this.Given(x => x.GivenTheReRoute(serviceConfig, reRoute))
            .When(x => x.WhenIGetTheServiceProvider())
            .Then(x => x.ThenTheServiceProviderIs <ConfigurationServiceProvider>())
            .BDDfy();
        }
        public void should_return_round_least_connection_balancer()
        {
            var reRoute = new ReRouteBuilder()
                          .WithLoadBalancer("LeastConnection")
                          .Build();

            this.Given(x => x.GivenAReRoute(reRoute))
            .And(x => x.GivenTheServiceProviderFactoryReturns())
            .When(x => x.WhenIGetTheLoadBalancer())
            .Then(x => x.ThenTheLoadBalancerIsReturned <LeastConnectionLoadBalancer>())
            .BDDfy();
        }
        public void should_call_service_provider()
        {
            var reRoute = new ReRouteBuilder()
                          .WithLoadBalancer("RoundRobin")
                          .Build();

            this.Given(x => x.GivenAReRoute(reRoute))
            .And(x => x.GivenTheServiceProviderFactoryReturns())
            .When(x => x.WhenIGetTheLoadBalancer())
            .Then(x => x.ThenTheServiceProviderIsCalledCorrectly())
            .BDDfy();
        }
        public void should_not_find_aggregator()
        {
            var reRoute = new ReRouteBuilder()
                          .WithAggregator("TestDefinedAggregator")
                          .Build();

            this.Given(_ => GivenNoDefinedAggregator())
            .And(_ => GivenReRoute(reRoute))
            .When(_ => WhenIGet())
            .Then(_ => ThenAnErrorIsReturned())
            .BDDfy();
        }
Beispiel #25
0
        public void should_fix_issue_142()
        {
            var consulPort    = 8500;
            var configuration = new FileConfiguration
            {
                GlobalConfiguration = new FileGlobalConfiguration()
                {
                    ServiceDiscoveryProvider = new FileServiceDiscoveryProvider()
                    {
                        Host = "localhost",
                        Port = consulPort
                    }
                }
            };

            var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";

            var serviceProviderConfig = new ServiceProviderConfigurationBuilder()
                                        .WithServiceDiscoveryProviderHost("localhost")
                                        .WithServiceDiscoveryProviderPort(consulPort)
                                        .Build();

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamPathTemplate("/status")
                          .WithUpstreamTemplatePattern("^(?i)/cs/status/$")
                          .WithDownstreamScheme("http")
                          .WithDownstreamHost("localhost")
                          .WithDownstreamPort(51779)
                          .WithUpstreamPathTemplate("/cs/status")
                          .WithUpstreamHttpMethod(new List <string> {
                "Get"
            })
                          .WithReRouteKey("/cs/status|Get")
                          .WithHttpHandlerOptions(new HttpHandlerOptions(true, false))
                          .Build();

            var reRoutes = new List <ReRoute> {
                reRoute
            };

            var config = new OcelotConfiguration(reRoutes, null, serviceProviderConfig);

            this.Given(x => GivenTheConsulConfigurationIs(config))
            .And(x => GivenThereIsAFakeConsulServiceDiscoveryProvider(fakeConsulServiceDiscoveryUrl))
            .And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51779", "/status", 200, "Hello from Laura"))
            .And(x => _steps.GivenThereIsAConfiguration(configuration))
            .And(x => _steps.GivenOcelotIsRunningUsingConsulToStoreConfig())
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/cs/status"))
            .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
            .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
            .BDDfy();
        }
Beispiel #26
0
        private ReRoute SetUpReRoute(FileReRoute fileReRoute, DownstreamReRoute downstreamReRoutes)
        {
            var upstreamTemplatePattern = _upstreamTemplatePatternCreator.Create(fileReRoute);

            var reRoute = new ReRouteBuilder()
                          .WithUpstreamHttpMethod(fileReRoute.UpstreamHttpMethod)
                          .WithUpstreamPathTemplate(upstreamTemplatePattern)
                          .WithDownstreamReRoute(downstreamReRoutes)
                          .WithUpstreamHost(fileReRoute.UpstreamHost)
                          .Build();

            return(reRoute);
        }
Beispiel #27
0
        public void should_store_load_balancers_by_key()
        {
            var reRoute    = new ReRouteBuilder().WithReRouteKey("test").Build();
            var reRouteTwo = new ReRouteBuilder().WithReRouteKey("testtwo").Build();

            this.Given(x => x.GivenThereIsALoadBalancer(reRoute, new FakeLoadBalancer()))
            .And(x => x.GivenThereIsALoadBalancer(reRouteTwo, new FakeRoundRobinLoadBalancer()))
            .When(x => x.WhenWeGetTheLoadBalancer(reRoute))
            .Then(x => x.ThenTheLoadBalancerIs <FakeLoadBalancer>())
            .When(x => x.WhenWeGetTheLoadBalancer(reRouteTwo))
            .Then(x => x.ThenTheLoadBalancerIs <FakeRoundRobinLoadBalancer>())
            .BDDfy();
        }
Beispiel #28
0
        public void should_get_new_load_balancer_if_reroute_load_balancer_has_changed()
        {
            var reRoute = new ReRouteBuilder().WithLoadBalancer("FakeLoadBalancer").WithReRouteKey("test").Build();

            var reRouteTwo = new ReRouteBuilder().WithLoadBalancer("LeastConnection").WithReRouteKey("test").Build();

            this.Given(x => x.GivenThereIsALoadBalancer(reRoute, new FakeLoadBalancer()))
            .When(x => x.WhenWeGetTheLoadBalancer(reRoute))
            .Then(x => x.ThenTheLoadBalancerIs <FakeLoadBalancer>())
            .When(x => x.WhenIGetTheReRouteWithTheSameKeyButDifferentLoadBalancer(reRouteTwo))
            .Then(x => x.ThenTheLoadBalancerIs <LeastConnection>())
            .BDDfy();
        }
Beispiel #29
0
        public void should_store_qos_providers_by_key()
        {
            var reRoute    = new ReRouteBuilder().WithReRouteKey("test").Build();
            var reRouteTwo = new ReRouteBuilder().WithReRouteKey("testTwo").Build();

            this.Given(x => x.GivenThereIsAQoSProvider(reRoute, new FakeQoSProvider()))
            .And(x => x.GivenThereIsAQoSProvider(reRouteTwo, new FakePollyQoSProvider()))
            .When(x => x.WhenWeGetTheQoSProvider(reRoute))
            .Then(x => x.ThenTheQoSProviderIs <FakeQoSProvider>())
            .When(x => x.WhenWeGetTheQoSProvider(reRouteTwo))
            .Then(x => x.ThenTheQoSProviderIs <FakePollyQoSProvider>())
            .BDDfy();
        }
Beispiel #30
0
        public void should_get_new_qos_provider_if_reroute_qos_provider_has_changed()
        {
            var reRoute = new ReRouteBuilder().WithReRouteKey("test").Build();

            var reRouteTwo = new ReRouteBuilder().WithReRouteKey("test").WithIsQos(true).Build();

            this.Given(x => x.GivenThereIsAQoSProvider(reRoute, new FakeQoSProvider()))
            .When(x => x.WhenWeGetTheQoSProvider(reRoute))
            .Then(x => x.ThenTheQoSProviderIs <FakeQoSProvider>())
            .When(x => x.WhenIGetTheReRouteWithTheSameKeyButDifferentQosProvider(reRouteTwo))
            .Then(x => x.ThenTheQoSProviderIs <FakePollyQoSProvider>())
            .BDDfy();
        }