public void testSameMap() { LinkMap.SetLinkToLow(false); Assert.AreEqual("/blog/Index.aspx", LinkMap.To(new Blog.BlogController().Index)); Assert.AreEqual("/blog/List.aspx", LinkMap.To(new Blog.BlogController().List)); Assert.AreEqual("/blog/Show/88.aspx", LinkMap.To(new Blog.BlogController().Show, 88)); Route x = LinkMap.Parse("/blog/Index"); Assert.AreEqual("Blog", x.ns); Assert.AreEqual("Blog", x.controller); Assert.AreEqual("Index", x.action); // 正常url x = LinkMap.Parse("/Blog/Blog/Index"); Assert.IsNull(x); x = LinkMap.Parse("/space/zhang/Blog1/Blog/Index"); Assert.IsNull(x); LinkMap.SetLinkToLow(true); x = LinkMap.Parse("/space/zhang/blog1/blog/index"); Assert.IsNull(x); }
public void testLinkFullStr() { LinkMap.SetLinkToLow(false); User u = new User { Id = 3, Url = "zhang" }; int appId = 5; Assert.AreEqual("/space/zhang/post5/Index.aspx", LinkMap.To(u, "TestPost", "Index", appId)); Assert.AreEqual("/space/zhang/category5.aspx", LinkMap.To(u, "TestPost", "List", appId)); Assert.AreEqual("/space/zhang/post5/Show/88.aspx", LinkMap.To(u, "TestPost", "Show", 88, appId)); Assert.AreEqual("/space/zhang/product5/99.aspx", LinkMap.To(u, "TestPost", "Product", 99, appId)); }
public void testLinkStr() { LinkMap.SetLinkToLow(false); Assert.AreEqual("/post/Index.aspx", LinkMap.To("TestPost", "Index")); Assert.AreEqual("/category.aspx", LinkMap.To("TestPost", "List")); Assert.AreEqual("/post/Show/88.aspx", LinkMap.To("TestPost", "Show", 88)); Assert.AreEqual("/product/99.aspx", LinkMap.To("TestPost", "Product", 99)); // 未映射的Link Assert.AreEqual(null, LinkMap.To("TestArticle", "Index")); Assert.AreEqual(null, LinkMap.To("TestArticle", "List")); Assert.AreEqual(null, LinkMap.To("TestArticle", "Show", 88)); Assert.AreEqual(null, LinkMap.To("TestArticle", "Product", 99)); }
public void testNsLink2() { LinkMap.SetLinkToLow(false); Assert.AreEqual("/u/Index.aspx", LinkMap.To(new Admin.Users.TestUserController().Index)); Assert.AreEqual("/u/List.aspx", LinkMap.To(new Admin.Users.TestUserController().List)); Assert.AreEqual("/u/Show/88.aspx", LinkMap.To(new Admin.Users.TestUserController().Show, 88)); Assert.AreEqual("/addr/99.aspx", LinkMap.To(new Admin.Users.TestUserController().Address, 99)); LinkMap.SetLinkToLow(true); Assert.AreEqual("/u/index.aspx", LinkMap.To(new Admin.Users.TestUserController().Index)); Assert.AreEqual("/u/list.aspx", LinkMap.To(new Admin.Users.TestUserController().List)); Assert.AreEqual("/u/show/88.aspx", LinkMap.To(new Admin.Users.TestUserController().Show, 88)); Assert.AreEqual("/addr/99.aspx", LinkMap.To(new Admin.Users.TestUserController().Address, 99)); }
public void testNsLink() { LinkMap.SetLinkToLow(false); Assert.AreEqual("/cm/Index.aspx", LinkMap.To(new Admin.TestCommentController().Index)); Assert.AreEqual("/cm/List.aspx", LinkMap.To(new Admin.TestCommentController().List)); Assert.AreEqual("/cm/Show/88.aspx", LinkMap.To(new Admin.TestCommentController().Show, 88)); Assert.AreEqual("/cm/Product/99.aspx", LinkMap.To(new Admin.TestCommentController().Product, 99)); LinkMap.SetLinkToLow(true); Assert.AreEqual("/cm/index.aspx", LinkMap.To(new Admin.TestCommentController().Index)); Assert.AreEqual("/cm/list.aspx", LinkMap.To(new Admin.TestCommentController().List)); Assert.AreEqual("/cm/show/88.aspx", LinkMap.To(new Admin.TestCommentController().Show, 88)); Assert.AreEqual("/cm/product/99.aspx", LinkMap.To(new Admin.TestCommentController().Product, 99)); }
public void testLinkFull() { LinkMap.SetLinkToLow(false); User u = new User { Id = 3, Url = "zhang" }; int appId = 5; Assert.AreEqual("/space/zhang/post5/Index.aspx", LinkMap.To(u, new TestPostController().Index, appId)); Assert.AreEqual("/space/zhang/category5.aspx", LinkMap.To(u, new TestPostController().List, appId)); Assert.AreEqual("/space/zhang/post5/Show/88.aspx", LinkMap.To(u, new TestPostController().Show, 88, appId)); Assert.AreEqual("/space/zhang/product5/99.aspx", LinkMap.To(u, new TestPostController().Product, 99, appId)); appId = 0; Assert.AreEqual("/space/zhang/post/Index.aspx", LinkMap.To(u, new TestPostController().Index, appId)); Assert.AreEqual("/space/zhang/category.aspx", LinkMap.To(u, new TestPostController().List, appId)); Assert.AreEqual("/space/zhang/post/Show/88.aspx", LinkMap.To(u, new TestPostController().Show, 88, appId)); Assert.AreEqual("/space/zhang/product/99.aspx", LinkMap.To(u, new TestPostController().Product, 99, appId)); LinkMap.SetLinkToLow(true); appId = 5; Assert.AreEqual("/space/zhang/post5/index.aspx", LinkMap.To(u, new TestPostController().Index, appId)); Assert.AreEqual("/space/zhang/category5.aspx", LinkMap.To(u, new TestPostController().List, appId)); Assert.AreEqual("/space/zhang/post5/show/88.aspx", LinkMap.To(u, new TestPostController().Show, 88, appId)); Assert.AreEqual("/space/zhang/product5/99.aspx", LinkMap.To(u, new TestPostController().Product, 99, appId)); Assert.AreEqual("/post5/index.aspx", LinkMap.To(null, new TestPostController().Index, appId)); Assert.AreEqual("/category5.aspx", LinkMap.To(null, new TestPostController().List, appId)); Assert.AreEqual("/post5/show/88.aspx", LinkMap.To(null, new TestPostController().Show, 88, appId)); Assert.AreEqual("/product5/99.aspx", LinkMap.To(null, new TestPostController().Product, 99, appId)); // 未映射的Link Assert.AreEqual(null, LinkMap.To(u, new TestArticleController().Index, appId)); Assert.AreEqual(null, LinkMap.To(u, new TestArticleController().List, appId)); Assert.AreEqual(null, LinkMap.To(u, new TestArticleController().Show, 88, appId)); Assert.AreEqual(null, LinkMap.To(u, new TestArticleController().Product, 99, appId)); }
public void testLink() { LinkMap.SetLinkToLow(false); Assert.AreEqual("/post/Index.aspx", LinkMap.To(new TestPostController().Index)); Assert.AreEqual("/category.aspx", LinkMap.To(new TestPostController().List)); Assert.AreEqual("/post/Show/88.aspx", LinkMap.To(new TestPostController().Show, 88)); Assert.AreEqual("/product/99.aspx", LinkMap.To(new TestPostController().Product, 99)); LinkMap.SetLinkToLow(true); Assert.AreEqual("/post/index.aspx", LinkMap.To(new TestPostController().Index)); Assert.AreEqual("/category.aspx", LinkMap.To(new TestPostController().List)); Assert.AreEqual("/post/show/88.aspx", LinkMap.To(new TestPostController().Show, 88)); Assert.AreEqual("/product/99.aspx", LinkMap.To(new TestPostController().Product, 99)); // 未映射的Link Assert.AreEqual(null, LinkMap.To(new TestArticleController().Index)); Assert.AreEqual(null, LinkMap.To(new TestArticleController().List)); Assert.AreEqual(null, LinkMap.To(new TestArticleController().Show, 88)); Assert.AreEqual(null, LinkMap.To(new TestArticleController().Product, 99)); }