public void InitializeTest()
        {
            CustomRouter target          = new CustomRouter(); // TODO: Initialize to an appropriate value
            string       absoluteSiteUrl = string.Empty;       // TODO: Initialize to an appropriate value
            SPFile       recordFile      = null;               // TODO: Initialize to an appropriate value
            string       contentTypeName = string.Empty;       // TODO: Initialize to an appropriate value

            target.Initialize(absoluteSiteUrl, recordFile, contentTypeName);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        public async void SetupCustomRouterAndLookForbadRoute()
        {
            var router  = new CustomRouter();
            var service = new Service(new string[] { "/test1/test2/test3/test4/test5" }, "Service1Test", "Address1Test", 10000, "node1", new string[0]);

            router.AddNewService(service);

            var context = new DefaultHttpContext();

            context.Request.Method = "GET";
            context.Request.Path   = "/test2/test2/test3/test4/test5/test6";
            var routeContext = new RouteContext(context);

            await router.RouteAsync(routeContext);

            Assert.Null(routeContext.Handler);
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CustomRouter customRouter)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.DefaultHandler = customRouter;
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
예제 #4
0
        public static void Start(IMvcApplication application)
        {
            var container = new ServiceCollection();

            application.ConfigureServices(container);

            var controllerRouter = new ControllerRouter(container);
            var resourceRouter   = new ResourceRouter();
            var customRouter     = new CustomRouter();

            var router = new HttpHandlerContext(controllerRouter, resourceRouter, customRouter);

            application.Configure();

            var server = new WebServer.WebServer(HOSTING_PORT, router);

            server.Run();
        }
        public static void Start(IMvcApplication application)
        {
            IDependencyContainer container = new DependencyContainer();

            application.ConfigureServices(container);

            IMvcRouter      controllerRouter = new ControllerRouter(container);
            IResourceRouter resourceRouter   = new ResourceRouter();
            ICustomRouter   customRouter     = new CustomRouter();

            IHttpRequestHandler httpRequestHandlingContext
                = new HttpRequestHandlingContext(controllerRouter, resourceRouter, customRouter);

            application.Configure();

            Server server = new Server(HostingPort, httpRequestHandlingContext);

            server.Run();
        }
예제 #6
0
        public async Task CanWeFindARouteAndGetAPage()
        {
            var router  = new CustomRouter();
            var service = new Service(new string[] { "/search" }, "Service1", "www.google.com", 80, "node1", new string[0]);

            router.AddNewService(service);

            var context = new DefaultHttpContext();

            context.Request.Method = "GET";
            context.Request.Path   = "/search";

            var routeContext = new RouteContext(context);

            await router.RouteAsync(routeContext);

            await routeContext.Handler.Invoke(routeContext.HttpContext);

            Assert.Equal(200, routeContext.HttpContext.Response.StatusCode);
        }
예제 #7
0
        private static async Task <RouteContext> RouteRequest(CustomRouter router,
                                                              string requestPath)
        {
            var context = new DefaultHttpContext();

            context.Request.Method = "GET";
            context.Request.Path   = requestPath;

            var routeContext = new RouteContext(context);

            await router.RouteAsync(routeContext);

            if (routeContext.Handler == null)
            {
                return(null);
            }

            await routeContext.Handler.Invoke(routeContext.HttpContext);

            return(routeContext);
        }