private CustomRouter BuildRouter() => new CustomRouter(null, RoutingData.BuildDefault(), new IService[0]);
Exemple #2
0
 private CustomRouter BuildRouter()
 {
     return(new CustomRouter(null, RoutingData.BuildDefault(), new IService[0]));
 }
Exemple #3
0
 private CustomRouter BuildRouter()
 {
     return(new CustomRouter(null, RoutingData.BuildDefault()));
 }
        public async Task CanRegisterRoutes()
        {
            var wait = new AsyncManualResetEvent <bool>();

            var agentAddress = "localhost";
            var config       = new CondenserConfiguration
            {
                AgentAddress = agentAddress,
                AgentPort    = 8500
            };
            var router = BuildRouter();

            var host = new RoutingHost(router, config, null, RoutingData.BuildDefault(),
                                       new IService[0], () => new Service(new CurrentState(), null))
            {
                OnRouteBuilt = servers =>
                {
                    {
                        if (servers.ContainsKey("Google"))
                        {
                            wait.Set(true);
                        }
                    }
                }
            };

            var google = new ServiceManager("Google",
                                            agentAddress, 8500)
            {
                ServiceAddress = "www.google.com",
                ServicePort    = 80
            };

            await google.AddApiUrl("/search")
            .RegisterServiceAsync();

            await wait.WaitAsync();

            var routeContext = await RouteRequest(router, "/search");

            Assert.Equal(200, routeContext.HttpContext.Response.StatusCode);

            google = new ServiceManager("Google", "Google2", agentAddress, 8500)
            {
                ServiceAddress = "www.google.com",
                ServicePort    = 80
            };

            wait.Reset();

            await google.AddApiUrl("/gmail")
            .AddHttpHealthCheck("/gmail", 10)
            .RegisterServiceAsync();

            await wait.WaitAsync();

            routeContext = await RouteRequest(router, "/gmail");

            Assert.Equal(200, routeContext.HttpContext.Response.StatusCode);

            routeContext = await RouteRequest(router, "/search");

            Assert.Null(routeContext);
        }