Exemplo n.º 1
0
        public void Can_create_mvc_route_to_method_with_actionName()
        {
            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}")
                        .ToDefaultAction <MvcRouteController>(x => x.WithActionNameAttribute());


            Assert.AreEqual("ChangedName", route.Defaults["action"]);
        }
Exemplo n.º 2
0
        public void Can_create_mvc_route_to_method_with_string_defaults()
        {
            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}")
                        .WithDefaults(new { controller = "home", action = "index" });

            Assert.AreEqual("home", route.Defaults["controller"]);
            Assert.AreEqual("index", route.Defaults["action"]);
        }
Exemplo n.º 3
0
        public void Can_create_mvc_route_with_constraints()
        {
            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}")
                        .WithConstraints(new { action = "^[a-Z]+$" })
                        .ToDefaultAction <MvcRouteController>(x => x.WithTwoArgs("mupp", null));

            Assert.AreEqual("^[a-Z]+$", route.Constraints["action"]);
        }
Exemplo n.º 4
0
        public void Can_create_mvc_route_with_default_controller_action_and_additional_defaults()
        {
            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}/{id}")
                        .ToDefaultAction <MvcRouteController>(x => x.Index(), new { id = "def" });

            Assert.AreEqual("MvcRoute", route.Defaults["controller"]);
            Assert.AreEqual("Index", route.Defaults["action"]);
            Assert.AreEqual("def", route.Defaults["id"]);
        }
Exemplo n.º 5
0
        public void Can_create_mvc_route_and_add_to_route_collection()
        {
            var routes = new RouteCollection();

            MvcRoute
            .MapUrl("test/{controller}/{action}")
            .ToDefaultAction <MvcRouteController>(x => x.WithTwoArgs("mupp", null))
            .AddWithName("TestName", routes);

            Assert.IsNotNull(routes["TestName"]);
        }
Exemplo n.º 6
0
        public void Can_create_mvc_route_with_namespaces()
        {
            var namespaces = new[] { "Namespace.One", "Namespace.Two" };

            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}")
                        .WithNamespaces(namespaces)
                        .ToDefaultAction <MvcRouteController>(x => x.WithTwoArgs("mupp", null));

            Assert.AreEqual(namespaces, route.DataTokens["Namespaces"]);
        }
Exemplo n.º 7
0
        public void Can_create_mvc_route_with_default_controller_action_and_parameter_defaults()
        {
            var route = MvcRoute
                        .MapUrl("test/{controller}/{action}")
                        .ToDefaultAction <MvcRouteController>(x => x.WithTwoArgs("mupp", null));

            Assert.AreEqual("MvcRoute", route.Defaults["controller"]);
            Assert.AreEqual("WithTwoArgs", route.Defaults["action"]);
            Assert.AreEqual("mupp", route.Defaults["arg1"]);
            Assert.IsFalse(route.Defaults.ContainsKey("arg2"));
        }