public virtual void TestTrailingPaddings() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo/action", "foo", "action", ":a" ), WebApp.ParseRoute("/foo/action//:a / ")); NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo/action", "foo", "action"), WebApp .ParseRoute("/foo/action / ")); }
public virtual void TestDefaultAction() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo", "foo", "index"), WebApp.ParseRoute ("/foo")); NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo", "foo", "index"), WebApp.ParseRoute ("/foo/")); }
// Dest may contain a candidate controller private Router.Dest ResolveAction(WebApp.HTTP method, Router.Dest dest, string path ) { if (dest.prefix.Length == 1) { return(null); } Preconditions.CheckState(!IsGoodMatch(dest, path), dest.prefix); Preconditions.CheckState(Slash.CountIn(path) > 1, path); IList <string> parts = WebApp.ParseRoute(path); string controller = parts[WebApp.RController]; string action = parts[WebApp.RAction]; return(Add(method, StringHelper.Pjoin(string.Empty, controller, action), dest.controllerClass , action, null)); }
// Assume /controller/action style path private Router.Dest ResolveDefault(WebApp.HTTP method, string path) { IList <string> parts = WebApp.ParseRoute(path); string controller = parts[WebApp.RController]; string action = parts[WebApp.RAction]; // NameController is encouraged default Type cls = Find <Controller>(StringHelper.Join(controller, "Controller")); if (cls == null) { cls = Find <Controller>(controller); } if (cls == null) { throw new WebAppException(StringHelper.Join(path, ": controller for ", controller , " not found")); } return(Add(method, DefaultPrefix(controller, action), cls, action, null)); }
public virtual void TestMissingLeadingSlash() { WebApp.ParseRoute("foo/bar"); }
public virtual void TestNormalAction() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo/action", "foo", "action", ":a1" , ":a2"), WebApp.ParseRoute("/foo/action/:a1/:a2")); }
public virtual void TestPartialCapture2() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo/action", "foo", "action", ":a1" , "bar", ":a2", ":a3"), WebApp.ParseRoute("/foo/action/:a1/bar/:a2/:a3")); }
public virtual void TestDefaultCapture() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/", "default", "index", ":a"), WebApp .ParseRoute("/:a")); }
public virtual void TestMissingAction() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo", "foo", "index", ":a1"), WebApp .ParseRoute("/foo/:a1")); }
public virtual void TestDefaultController() { NUnit.Framework.Assert.AreEqual(Arrays.AsList("/", "default", "index"), WebApp.ParseRoute ("/")); }