如何将以下类移植到ASP.NET MVC3?它是基于ASP.NET MVC2的MVC: Unit testing controller actions that use TempData文章的一部分。方法RenderView()不再存在,并且具有不同的参数。
感谢。
// Test-specific subclass for HomeController. This won't be
// needed in the next release of ASP.NET MVC.
private sealed class TestHomeController : HomeController {
public RouteValueDictionary RedirectValues;
public string RenderViewName;
public string RenderMasterName;
public object RenderViewData;
protected override void RedirectToAction(RouteValueDictionary values) {
RedirectValues = values;
}
protected override void RenderView(string viewName, string masterName,
object viewData) {
RenderViewName = viewName;
RenderMasterName = masterName;
RenderViewData = viewData;
}
}
答案 0 :(得分:0)
我终于发现了一篇关于如何在ASP.NET MVC 3中测试TempData的有趣文章:https://web.archive.org/web/20150419085935/http://www.arrangeactassert.com/how-to-unit-test-asp-net-mvc-controllers/