public void Layout_And_View_Should_Have_ViewContext() { _mocks.ReplayAll(); BrailBase view = _viewEngine.Process("view", "/Master"); _viewContext = new ViewContext(controllerContext, view, new ViewDataDictionary(), new TempDataDictionary(), new StringWriter()); view.Render(_viewContext, _httpContext.Response.Output); Assert.IsNotNull(view.ViewContext); Assert.AreEqual(view.ViewContext, view.Layout.ViewContext); }
protected string ProcessView(string templatePath) { var sw = new StringWriter(); ControllerContext.LayoutNames = Layouts; StubEngineContext.CurrentControllerContext = ControllerContext; BooViewEngine.Process(templatePath, sw, StubEngineContext, null, ControllerContext); lastOutput = sw.ToString(); return(lastOutput); }
public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { var controller = controllerContext.RouteData.Values["controller"] as string; string fullViewName = string.Concat(controller, "/", viewName); IView view = _viewEngine.Process(fullViewName, masterName); return(new ViewEngineResult(view, this)); }
public void CanRenderViewWithoutUsingFullMonoRailPipeline() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DummyController controller = new DummyController(); PrepareController(controller, "", "home", "index"); bve.Process(sw, Context, controller, "home/index"); Assert.AreEqual("Brail is wonderful", sw.ToString()); }
public void CanOutputParagraphWithClassAttribute() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); PrepareController(controller, "", "dsl", "attributeOutput"); bve.Process(sw, Context, controller, "dsl/attributeOutput"); Assert.AreEqual("<html><p class=\"foo\">hello world</p></html>", sw.ToString()); }
public void RegisterHtmlAllowsCallToHtml() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); PrepareController(controller, "", "dsl", "registerHtml"); bve.Process(sw, Context, controller, "dsl/registerHtml"); Assert.AreEqual(@"<html>hello world</html>", sw.ToString()); }
public void ParametersCanBeReferencedByView() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); controller.PropertyBag["SayHelloTo"] = "Harris"; PrepareController(controller, "", "dsl", "expandParameters"); bve.Process(sw, Context, controller, "dsl/expandParameters"); Assert.AreEqual("<html><p>hello, Harris</p></html>", sw.ToString()); }
protected string ProcessView(IDictionary dictionary, string templatePath) { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DummyController controller = new DummyController(); controller.PropertyBag = dictionary; PrepareController(controller, "", "home", "index"); bve.Process(sw, Context, controller, templatePath); return sw.ToString(); }