我想在单元测试中测试我的路线。但是 Areas 在我的单元测试中不起作用。是否可以测试区域的 ASP.NET MVC 2 路由?
我正在使用此代码
[SetUp]
public void SetUp()
{
this.routes = new RouteCollection();
MvcApplication.RegisterRoutes(this.routes);
}
#endregion
private RouteCollection routes;
[Test]
public void Should_Navigate_To_AdminUser_Controller_EditUser_Method()
{
HttpContextBase fackeCtx = CreateFackeContext("~/Admin/User/Edit/3");
RouteData routeData = this.routes.GetRouteData(fackeCtx);
Assert.IsNotNull(routeData,
"Route is not defined!");
Assert.AreEqual("Edit",
routeData.Values["action"]);
Assert.AreEqual("User",
routeData.Values["controller"]);
Assert.AreEqual("3",
routeData.Values["id"]);
}