code_junkie

How should i make this ASP.NET MVC Route

Nov 14th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. - http://www.mysite.com/
  2. - http://www.mysite.com/?page=2
  3. - http://www.mysite.com/?tags=fooBar
  4. - http://www.mysite.com/?page=2&tags=fooBar
  5.  
  6. // Arrange.
  7. var routes = new RouteCollection();
  8. MvcApplication.RegisterRoutes(routes);
  9.  
  10. // Act.
  11. context = new FakeHttpContext("~/?page=2&tags=fooBar");
  12. routeData = routes.GetRouteData(context);
  13.  
  14. // Assert.
  15. Assert.AreEqual("Home", routeData.Values["controller"]);
  16. Assert.AreEqual("Index", routeData.Values["action"]);
  17. Assert.AreEqual(2, routeData.Values["page"]);
  18. Assert.AreEqual("fooBar", routeData.Values["tags"]);
  19.  
  20. URL: http://www.mysite.com/?page=2&tags=fooBar
  21.  
  22. public ActionResult Index(string page, string tags)
  23. {
  24. ViewData["Message"] = string.Format("Page={0}, Tags={1}", page, tags);
  25. return View();
  26. }
Add Comment
Please, Sign In to add comment