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"]); }
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"]); }
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"]); }
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"]); }
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"]); }
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"]); }
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")); }