예제 #1
0
 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 / "));
 }
예제 #2
0
 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/"));
 }
예제 #3
0
        // 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));
        }
예제 #4
0
        // 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));
        }
예제 #5
0
 public virtual void TestMissingLeadingSlash()
 {
     WebApp.ParseRoute("foo/bar");
 }
예제 #6
0
 public virtual void TestNormalAction()
 {
     NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo/action", "foo", "action", ":a1"
                                                   , ":a2"), WebApp.ParseRoute("/foo/action/:a1/:a2"));
 }
예제 #7
0
 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"));
 }
예제 #8
0
 public virtual void TestDefaultCapture()
 {
     NUnit.Framework.Assert.AreEqual(Arrays.AsList("/", "default", "index", ":a"), WebApp
                                     .ParseRoute("/:a"));
 }
예제 #9
0
 public virtual void TestMissingAction()
 {
     NUnit.Framework.Assert.AreEqual(Arrays.AsList("/foo", "foo", "index", ":a1"), WebApp
                                     .ParseRoute("/foo/:a1"));
 }
예제 #10
0
 public virtual void TestDefaultController()
 {
     NUnit.Framework.Assert.AreEqual(Arrays.AsList("/", "default", "index"), WebApp.ParseRoute
                                         ("/"));
 }