Example #1
0
        private ViewEngineBase GetBrailEngine()
        {
            var engine = new BooViewEngine();

            engine.Options = new BooViewEngineOptions();
            engine.Options.SaveDirectory = Environment.CurrentDirectory;
            engine.Options.SaveToDisk    = false;
            engine.Options.Debug         = true;
            engine.Options.BatchCompile  = false;

            engine.SetViewSourceLoader(_viewSourceLoader);
            engine.Initialize();
            return(engine);
        }
		public void SetUp()
		{
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			StubMonoRailServices services = new StubMonoRailServices();
			services.UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine());
			services.UrlTokenizer = new DefaultUrlTokenizer();
			UrlInfo urlInfo = new UrlInfo(
				"example.org", "test", "/TestBrail", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
													  urlInfo);
			StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(StubEngineContext);
			ViewComponentFactory.Initialize();

			StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			ControllerContext = new ControllerContext();
			ControllerContext.Helpers = Helpers;
			ControllerContext.PropertyBag = PropertyBag;
			StubEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["formhelper"] = Helpers["form"] = new FormHelper(StubEngineContext);
			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);

			string viewPath = Path.Combine(viewSourcePath, "Views");

			FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
			loader.AddAssemblySource(
				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

			BooViewEngine = new BooViewEngine();
			BooViewEngine.Options = new BooViewEngineOptions();
			BooViewEngine.Options.SaveDirectory = Environment.CurrentDirectory;
			BooViewEngine.Options.SaveToDisk = false;
			BooViewEngine.Options.Debug = true;
			BooViewEngine.Options.BatchCompile = false;

			BooViewEngine.SetViewSourceLoader(loader);
			BooViewEngine.Initialize();

			BeforEachTest();
		}
Example #3
0
        public void SetUp()
        {
            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            var services = new StubMonoRailServices
            {
                UrlBuilder   = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
                UrlTokenizer = new DefaultUrlTokenizer()
            };
            var urlInfo = new UrlInfo(
                "example.org", "test", "/TestBrail", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
                                                      urlInfo);
            StubEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            StubEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);

            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(StubEngineContext);

            StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            ControllerContext = new ControllerContext
            {
                Helpers     = Helpers,
                PropertyBag = PropertyBag
            };
            StubEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["formhelper"]       = Helpers["form"] = new FormHelper(StubEngineContext);
            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(StubEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(StubEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);

            var viewPath = Path.Combine(viewSourcePath, "Views");

            var loader = new FileAssemblyViewSourceLoader(viewPath);

            loader.AddAssemblySource(
                new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
                                       "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

            BooViewEngine = new BooViewEngine
            {
                Options = new BooViewEngineOptions
                {
                    SaveDirectory = Environment.CurrentDirectory,
                    SaveToDisk    = false,
                    Debug         = true,
                    BatchCompile  = false
                }
            };

            BooViewEngine.SetViewSourceLoader(loader);
            BooViewEngine.Initialize();

            BeforEachTest();
        }