我想在单元测试中测试我的路线。但是区域在我的单元测试中不起作用。 是否可以测试区域的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"]);
}