private ViewEngineResult ViewResultFor(string view) { var controller = new NewsController(); var routeData = new RouteData(); routeData.Values["controller"] = "News"; controller.ControllerContext = new ControllerContext(new RequestContext(SystemManager.CurrentHttpContext, routeData), controller); FrontendControllerFactory.EnhanceViewEngines(controller); return(controller.ViewEngineCollection.FindView(controller.ControllerContext, view, null)); }
public void Designer_UsesPrecompiledView() { var controller = new DesignerController(); var routeData = new RouteData(); routeData.Values["controller"] = "Designer"; routeData.Values["widgetName"] = "News"; controller.ControllerContext = new ControllerContext(new RequestContext(SystemManager.CurrentHttpContext, routeData), controller); FrontendControllerFactory.EnhanceViewEngines(controller); var viewResult = controller.ViewEngineCollection.FindView(controller.ControllerContext, "Designer", null); Assert.IsNotNull(viewResult, "View result is null."); Assert.IsNotNull(viewResult.View, "The view was not found."); Assert.IsInstanceOfType <PrecompiledMvcView>(viewResult.View, "The view is not precompiled."); viewResult = controller.ViewEngineCollection.FindView(controller.ControllerContext, "DesignerView.Simple", null); Assert.IsNotNull(viewResult, "View result is null."); Assert.IsNotNull(viewResult.View, "The view was not found."); Assert.IsInstanceOfType <PrecompiledMvcView>(viewResult.View, "The view is not precompiled."); }