mvccontrib-testhelper

Looking for direction on unit testing a controller extension that renders a partial view

霸气de小男生 提交于 2019-11-30 13:56:29
问题 As the title says, I'm looking for direction on how to properly test a controller extension. The extension renders a partial view which in turn I'm using within a JSONResult: public static string RenderPartialViewToString(this Controller controller, string viewName = null, object model = null) { if (string.IsNullOrEmpty(viewName)) { viewName = controller.ControllerContext.RouteData.GetRequiredString("action"); } controller.ViewData.Model = model; using (StringWriter sw = new StringWriter()) {