コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: BrailViewFactory.cs プロジェクト: kermina/Brail
        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));
        }
コード例 #4
0
		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());
		}
コード例 #5
0
ファイル: DslFixture.cs プロジェクト: nats/castle-1.0.3-mono
 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());
 }
コード例 #6
0
ファイル: DslFixture.cs プロジェクト: nats/castle-1.0.3-mono
 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());
 }
コード例 #7
0
ファイル: DslFixture.cs プロジェクト: nats/castle-1.0.3-mono
 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());
 }
コード例 #8
0
		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();
		}