0
我正在嘗試爲MVC 3路由編寫測試,但仍未找到匹配項。爲什麼這在測試中不起作用?我正在關閉http://haacked.com/archive/2007/12/17/testing-routes-in-asp.net-mvc.aspx,並從查看MVC代碼,它可能與VirtualPathProvider有關?使用MOQ未找到另一個ASP.NET MVC路由
[TestMethod]
public void TestRoutes()
{
string url = "~/en-us/Client/1/DownloadTemplate";
var httpContextMock = new Mock<HttpContextBase>();
httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath)
.Returns(url);
RouteCollection routes = new RouteCollection();
MvcApplication.RegisterRoutes(routes);
var routeData = routes.GetRouteData(httpContextMock.Object);
// routeData is null!
Assert.AreEqual("import", routeData.Values["controller"].ToString());
Assert.AreEqual("DownloadTemplate", routeData.Values["action"].ToString());
}
你解決了你的問題嗎? –