Exemple #1
0
        public static void Main()
        {
            var router = new BlackApplication().Routes;
            Route root = null, item = null, custom = null,subShow = null;
            root= router.RootRoute = new Route()
            {
                ControllerType = typeof(TestRootRouteController),
                ActionName = "Index",
                Name="/"
            };

            router.RootRoute.DynamicRoute = item = new Route()
            {
                ControllerType = typeof(TestRootRouteController),
                ActionName = "Item",
                Name="id"
            };

            item.MemberRoutes.Add(custom = new Route()
            {
                ControllerType = typeof(TestRootRouteController),
                ActionName = "Custom",
                Name="custom"
            });
            var result = router.Evaluate("/34/custom");
        }
 public void TestRootRoute()
 {
     var router = new BlackApplication().Routes;
     router.NotFoundRoute = new Route()
     {
         ControllerType = typeof(TestRootRouteController),
         ActionName = "NotFound",
         Name=""
     };
     router.RootRoute = new Route()
     {
         ControllerType = typeof(TestRootRouteController),
         ActionName = "Index",
         Name="/"
     };
     Assert.AreEqual(router.RootRoute,router.Evaluate("/").Route);
 }
 public void TestNotFoundRoute()
 {
     var router = new BlackApplication().Routes;
     router.RootRoute = new Route()
     {
         ControllerType = typeof(RoutingController),
         ActionName = "Index",
         Name="/"
     };
     router.NotFoundRoute = new Route()
     {
         ControllerType = typeof(RoutingController),
         ActionName = "NotFound",
         Name="/lost"
     };
     Assert.AreEqual(router.NotFoundRoute,router.Evaluate("/this_route_does_not_exists_at_all").Route);
     Assert.AreEqual(router.NotFoundRoute,router.Evaluate("/this/route/does/not/exists/at/all").Route);
 }
        public void TestDynamicRoutesAndMemberRoutes()
        {
            var router = new BlackApplication().Routes;
            Route root = null, item = null, custom = null,subShow = null;
            root= router.RootRoute = new Route()
            {
                ControllerType = typeof(TestDynamicRoutesAndMemberRoutesController),
                ActionName = "Index",
                Name="/"
            };

            router.RootRoute.DynamicRoute = item = new Route()
            {
                ControllerType = typeof(TestDynamicRoutesAndMemberRoutesController),
                ActionName = "Item",
                Name="id"
            };

            item.MemberRoutes.Add(custom = new Route()
            {
                ControllerType = typeof(TestDynamicRoutesAndMemberRoutesController),
                ActionName = "Custom",
                Name="custom"
            });
            custom.DynamicRoute = new Route()
            {
                ActionName ="Item",
                Name = "id",
                ControllerType = typeof(SubRouteController)
            };

            Assert.AreEqual(router.RootRoute,router.Evaluate("/").Route,"Route / should be found for /");
            Assert.AreEqual(item,router.Evaluate("/23").Route,"Route Controller.Item should be found for /23");
            Assert.AreEqual(item,router.Evaluate("/23/").Route,"Route Controller.Item should be found for /23/");
            Assert.AreEqual(custom,router.Evaluate("/23/custom").Route,"Route Controller.Custom should be found for /23/custom");
            Assert.AreEqual(custom,router.Evaluate("/23/custom/").Route,"Route Controller.Custom should be found for /23/custom/");
            Assert.AreEqual(custom,router.Evaluate("/23/Custom").Route,"Route Controller.Custom should be found for /23/Custom (routing is case insensitive)");
            Assert.AreEqual(custom.DynamicRoute,router.Evaluate("/23/custom/23").Route,"Route Controller.Custom.DinamicRoute should be found for /23/custom/23");
        }
 public BlackContext(BlackApplication applicationInstance, string resourcePath)
 {
     this.ApplicationInstance = applicationInstance;
     this.ResourcePath        = resourcePath;
 }