public void should_apply_filters()
        {
            
            var filters = new List<INavigationRouteFilter>();
            filters.Add(new RemoveAuthorizeActions());
            
            var routes = new System.Web.Routing.RouteCollection();
            routes.MapNavigationRoute<HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute<HomeController>("Logout", c => c.Logout());

            var currentRoutes = NavigationRoutes.NavigationViewExtensions.GetRoutesForCurrentRequest(routes, filters);
            currentRoutes.Count().ShouldEqual(1);
        }
        public void Map_a_route_to_a_url_matching_the_action_name()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute<HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute<HomeController>("About", c => c.About());

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);

            uh.RouteUrl("Navigation-Home-About").ShouldEqual("/about"); 
        }
        public void Map_home_index_to_the_site_root()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute<HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute<HomeController>("About", c => c.About());
            routes.MapNavigationRoute<HomeController>("Logout", c => c.Logout());

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);
            uh.RouteUrl("Navigation-Home-Index").ShouldEqual("/");
        }
示例#4
0
        public void Map_a_route_to_a_url_matching_the_action_name()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute <HomeController>("About", c => c.About());

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);

            uh.RouteUrl("Navigation-Home-About").ShouldEqual("/about");
        }
示例#5
0
        public void Map_home_index_to_the_site_root()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute <HomeController>("About", c => c.About());
            routes.MapNavigationRoute <HomeController>("Logout", c => c.Logout());

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);

            uh.RouteUrl("Navigation-Home-Index").ShouldEqual("/");
        }
示例#6
0
        public void should_apply_filters()
        {
            var filters = new List <INavigationRouteFilter>();

            filters.Add(new RemoveAuthorizeActions());

            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index());
            routes.MapNavigationRoute <HomeController>("Logout", c => c.Logout());

            var currentRoutes = NavigationRoutes.NavigationViewExtensions.GetRoutesForCurrentRequest(routes, filters);

            currentRoutes.Count().ShouldEqual(1);
        }
        public void Map_a_route_to_a_url_using_an_area()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute<HomeController>("Home", c => c.Index(),"Admin");
            routes.MapNavigationRoute<HomeController>("About", c => c.About(),"AdMin");

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);

            uh.RouteUrl("Navigation-Admin-Home-About").ShouldEqual("/admin/about");
            var r = (Route)routes["Navigation-Admin-Home-About"];
            r.DataTokens["area"].ToString().ShouldEqual("admin");
            
            uh.RouteUrl("Navigation-AdMin-Home-Index").ShouldEqual("/admin");
        }
        public void add_namespaces_for_controller()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute<HomeController>("Home", c => c.Index());

            routes.Count().ShouldEqual(1);
            var namespaces = (string[]) ((NamedRoute) routes["Navigation-Home-Index"]).DataTokens["Namespaces"];
            namespaces.ShouldContain("UnitTests");
        }
        public void should_contain_child_routes()
        {
            var routes = new System.Web.Routing.RouteCollection();
            routes.MapNavigationRoute<HomeController>("Home", c => c.Index())
            .AddChildRoute<HomeController>("Logout", c => c.Logout())
            .AddChildRoute<HomeController>("Foobar", c => c.ChangePassword());

            routes.Count().ShouldEqual(3);
            ((NamedRoute)routes["Navigation-Home-Index"]).Children.Count().ShouldEqual(2);
        }
        public void add_namespaces()
        {
            var routes = new System.Web.Routing.RouteCollection();
            routes.MapNavigationRoute("Home-navigation", "Home", "",
                                        defaults: new { controller = "Home", action = "Index" },
                                        namespaces: new[] { "UnitTests" });
            routes.Count().ShouldEqual(1);

            var namespaces = (string[]) ((NamedRoute) routes["Home-navigation"]).DataTokens["Namespaces"];
            namespaces.ShouldContain("UnitTests");
        }
        public void add_filter_tokens()
        {
            var filterTokenText = "foo";
            var routes = new System.Web.Routing.RouteCollection();
            routes.MapNavigationRoute<HomeController>("Home", c => c.Index(), "", new NavigationRouteOptions { FilterToken = filterTokenText });

            Assert.IsTrue(((NamedRoute)routes["Navigation-Home-Index"]).DataTokens.HasFilterToken());

            var filterToken = (string)((NamedRoute)routes["Navigation-Home-Index"]).DataTokens.FilterToken();
            filterToken.ShouldEqual(filterTokenText);
        }
示例#12
0
        public void should_contain_child_routes()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index())
            .AddChildRoute <HomeController>("Logout", c => c.Logout())
            .AddChildRoute <HomeController>("Foobar", c => c.ChangePassword());

            routes.Count().ShouldEqual(3);
            ((NamedRoute)routes["Navigation-Home-Index"]).Children.Count().ShouldEqual(2);
        }
示例#13
0
        public void add_namespaces_for_controller()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index());

            routes.Count().ShouldEqual(1);
            var namespaces = (string[])((NamedRoute)routes["Navigation-Home-Index"]).DataTokens["Namespaces"];

            namespaces.ShouldContain("UnitTests");
        }
示例#14
0
        public void Map_a_route_to_a_url_using_an_area()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index(), "", new NavigationRouteOptions {
                AreaName = "Admin"
            });
            routes.MapNavigationRoute <HomeController>("About", c => c.About(), "", new NavigationRouteOptions {
                AreaName = "AdMin"
            });

            routes.Count.ShouldNotEqual(0);

            var uh = GetUrlHelper(routes);

            uh.RouteUrl("Navigation-Admin-Home-About").ShouldEqual("/admin/about");
            var r = (Route)routes["Navigation-Admin-Home-About"];

            r.DataTokens["area"].ToString().ShouldEqual("admin");

            uh.RouteUrl("Navigation-AdMin-Home-Index").ShouldEqual("/admin");
        }
示例#15
0
        public void add_namespaces()
        {
            var routes = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute("Home-navigation", "Home", "",
                                      defaults: new { controller = "Home", action = "Index" },
                                      namespaces: new[] { "UnitTests" });
            routes.Count().ShouldEqual(1);

            var namespaces = (string[])((NamedRoute)routes["Home-navigation"]).DataTokens["Namespaces"];

            namespaces.ShouldContain("UnitTests");
        }
示例#16
0
        public void add_filter_tokens()
        {
            var filterTokenText = "foo";
            var routes          = new System.Web.Routing.RouteCollection();

            routes.MapNavigationRoute <HomeController>("Home", c => c.Index(), "", new NavigationRouteOptions {
                FilterToken = filterTokenText
            });

            Assert.IsTrue(((NamedRoute)routes["Navigation-Home-Index"]).DataTokens.HasFilterToken());

            var filterToken = (string)((NamedRoute)routes["Navigation-Home-Index"]).DataTokens.FilterToken();

            filterToken.ShouldEqual(filterTokenText);
        }