public void Init() { mocks = new MockRepository(); serviceProvider = new StubMonoRailServices(); var viewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); viewSourceLoader.Service(this.serviceProvider); serviceProvider.ViewSourceLoader = viewSourceLoader; serviceProvider.AddService(typeof(IViewSourceLoader), viewSourceLoader); Configure(); controllerContext = new ControllerContext(); propertyBag = controllerContext.PropertyBag; controllerContext.LayoutNames = new [] { "default" }; output = new StringWriter(); server = new StubServerUtility(); routingEngine = MockRepository.GenerateMock <IRoutingEngine>(); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); serviceProvider.UrlBuilder = urlBuilder; serviceProvider.AddService(typeof(IUrlBuilder), urlBuilder); InitUrlInfo("", "home", "index"); response = engineContext.Response; }
public static IViewEngineManager GetViewManager() { var config = new MonoRailConfiguration(); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); config.ViewEngineConfig.ViewPathRoot = Path.Combine(@"..\..\..\AdminInterface", "Views"); var provider = new FakeServiceProvider(); var loader = new FileAssemblyViewSourceLoader(config.ViewEngineConfig.ViewPathRoot); loader.AddAssemblySource(new AssemblySourceInfo("Common.Web.Ui", "Common.Web.Ui.Views")); provider.Services.Add(typeof(IMonoRailConfiguration), config); provider.Services.Add(typeof(IViewSourceLoader), loader); var manager = new DefaultViewEngineManager(); manager.Service(provider); var options = Exposed.From(manager).viewEnginesFastLookup[0].Options; var namespaces = options.NamespacesToImport; namespaces.Add("Boo.Lang.Builtins"); namespaces.Add("AdminInterface.Helpers"); namespaces.Add("Common.Web.Ui.Helpers"); options.AssembliesToReference.Add(Assembly.Load("AdminInterface")); return(manager); }
public object GetService(Type serviceType) { if (typeof (IViewSourceLoader) == serviceType) { FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(); loader.ViewRootDir = viewRootDir; return loader; } return null; }
public override void SetUp() { base.SetUp(); _engineContext = MockRepository.GenerateMock <IEngineContext>(); _controller = MockRepository.GenerateMock <IController>(); _controllerContext = MockRepository.GenerateMock <IControllerContext>(); var serviceProvider = MockRepository.GenerateMock <IServiceProvider>(); var viewSourceLoader = new FileAssemblyViewSourceLoader(@"ViewTests\Views"); serviceProvider.Expect(x => x.GetService(typeof(IViewSourceLoader))).Return(viewSourceLoader); _engine = new RubyViewEngine(); _engine.Service(serviceProvider); }
public virtual void SetUp() { 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); ViewComponentFactory.Initialize(); StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory); ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag }; StubEngineContext.CurrentControllerContext = ControllerContext; Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext); Helpers["formhelper"] = Helpers["form"] = new FormHelper(StubEngineContext); Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext); Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext); var loader = new FileAssemblyViewSourceLoader("Views"); _monoRailViewEngine = new NHamlMonoRailViewEngine(); _monoRailViewEngine.TemplateEngine.Options.TemplateCompiler = new CSharp3TemplateCompiler(); _monoRailViewEngine.SetViewSourceLoader(loader); _templateEngine = _monoRailViewEngine.TemplateEngine; _templateEngine.Options.TemplateBaseType = typeof(NHamlMonoRailView); ViewComponentFactory.Inspect(GetType().Assembly); }
public override void SetUp() { base.SetUp(); // // string Area = null; // string ControllerName = "test_controller"; // string Action = "test_action"; // // var 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"); // _engineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services, urlInfo); // _engineContext.AddService(typeof(IUrlBuilder), services.UrlBuilder); // _engineContext.AddService(typeof(IUrlTokenizer), services.UrlTokenizer); // // // _engineContext.AddService<IViewComponentFactory>(ViewComponentFactory); // _controllerContext= new ControllerContext(); // _controllerContext.Helpers = Helpers; // _controllerContext.PropertyBag = PropertyBag; // StubEngineContext.CurrentControllerContext = _controllerContext; // // // ViewComponentFactory = new DefaultViewComponentFactory(); // ViewComponentFactory.Service(StubEngineContext); // ViewComponentFactory.Initialize(); // // Helpers = new HelperDictionary(); // Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(_engineContext); // Helpers["htmlhelper"] = Helpers["html"] = new HtmlHelper(_engineContext); // Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(_engineContext); // Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(_engineContext); // // string viewPath = Path.Combine(viewSourcePath, "Views"); // // FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath); _controller = MockRepository.GenerateMock <IController>(); _controllerContext = MockRepository.GenerateMock <IControllerContext>(); _serviceProvider = MockRepository.GenerateMock <IServiceProvider>(); _viewSourceLoader = new FileAssemblyViewSourceLoader(@"Views"); _serviceProvider.Expect(x => x.GetService(typeof(IViewSourceLoader))).Return(_viewSourceLoader); }
public static IViewEngineManager Init(Assembly assembly = null) { if (assembly == null) { assembly = Assembly.GetEntryAssembly(); } ActiveRecordStarter.Initialize( new[] { Assembly.Load("AdminInterface"), Assembly.Load("Common.Web.Ui") }, ActiveRecordSectionHandler.Instance); var config = new MonoRailConfiguration(); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); var loader = new FileAssemblyViewSourceLoader(""); loader.AddAssemblySource(new AssemblySourceInfo(assembly, assembly.GetName().Name + ".Views")); var provider = new FakeServiceProvider(); provider.Services.Add(typeof(IMonoRailConfiguration), config); provider.Services.Add(typeof(IViewSourceLoader), loader); var manager = new DefaultViewEngineManager(); manager.Service(provider); var options = ((BooViewEngine)manager.ResolveEngine(".brail")).Options; options.AssembliesToReference.Add(Assembly.Load("Common.Web.Ui")); var namespaces = options.NamespacesToImport; namespaces.Add("Boo.Lang.Builtins"); namespaces.Add("AdminInterface.Helpers"); namespaces.Add("Common.Web.Ui.Helpers"); BaseMailer.ViewEngineManager = manager; return(manager); }
public void SetUp() { var en = CultureInfo.CreateSpecificCulture("en"); Thread.CurrentThread.CurrentCulture = en; Thread.CurrentThread.CurrentUICulture = en; Layout = null; PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase); Helpers = new HelperDictionary(); var services = new StubMonoRailServices { UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()), UrlTokenizer = new DefaultUrlTokenizer(), CacheProvider = new StubCacheProvider() }; services.AddService(typeof(ICacheProvider), services.CacheProvider); var urlInfo = new UrlInfo( "example.org", "test", "", "http", 80, "http://test.example.org/test_area/test_controller/test_action.tdd", Area, ControllerName, Action, "tdd", "no.idea"); Response = new StubResponse(); EngineContext = new StubEngineContext(new StubRequest(), Response, services, urlInfo); services.AddService(typeof(IEngineContext), EngineContext); EngineContext.AddService<IEngineContext>(EngineContext); EngineContext.AddService<IUrlBuilder>(services.UrlBuilder); EngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer); EngineContext.AddService<ICacheProvider>(services.CacheProvider); ViewComponentFactory = new DefaultViewComponentFactory(); ViewComponentFactory.Service(EngineContext); EngineContext.AddService<IViewComponentFactory>(ViewComponentFactory); services.AddService(typeof(IViewComponentFactory), ViewComponentFactory); EngineContext.AddService<IViewComponentDescriptorProvider>(new DefaultViewComponentDescriptorProvider()); services.AddService(typeof(IViewComponentDescriptorProvider), EngineContext.GetService<IViewComponentDescriptorProvider>()); ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag }; EngineContext.CurrentControllerContext = ControllerContext; Helpers["formhelper"] = Helpers["form"] = new FormHelper(EngineContext); Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(EngineContext); Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(EngineContext); Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(EngineContext); var viewPath = Path.Combine(ViewSourcePath, "Views"); var loader = new FileAssemblyViewSourceLoader(viewPath); services.ViewSourceLoader = loader; services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); EngineContext.AddService<IViewSourceLoader>(services.ViewSourceLoader); Controller = new BaseTestFixtureController(); Controller.Contextualize(EngineContext, ControllerContext); VelocityViewEngine = new NVelocityViewEngine(); services.AddService(typeof(IViewEngine), VelocityViewEngine); EngineContext.AddService<IViewEngine>(VelocityViewEngine); VelocityViewEngine.SetViewSourceLoader(loader); VelocityViewEngine.Service(services); var viewEngineManager = new DefaultViewEngineManager(); viewEngineManager.RegisterEngineForExtesionLookup(VelocityViewEngine); services.EmailTemplateService = new EmailTemplateService(viewEngineManager); BeforEachTest(); }
public void SetUp() { loader = new FileAssemblyViewSourceLoader { ViewRootDir = Directory.GetCurrentDirectory() }; }
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(); }
public void SetUp() { loader = new FileAssemblyViewSourceLoader { ViewRootDir = Path.GetFullPath(@"c:\idontexist") }; }
public void SetUp() { loader = new FileAssemblyViewSourceLoader(); loader.ViewRootDir = Path.GetFullPath(@"c:\idontexist"); loader.Service(new TestServiceContainer()); }
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(); }
public void Init() { mocks = new MockRepository(); factory = new SparkViewFactory(); engineContext = mocks.CreateMock <IEngineContext>(); server = new MockServerUtility(); request = mocks.CreateMock <IRequest>(); response = mocks.CreateMock <IResponse>(); controller = mocks.CreateMock <IController>(); controllerContext = mocks.CreateMock <IControllerContext>(); routingEngine = mocks.CreateMock <IRoutingEngine>(); output = new StringWriter(); helpers = new HelperDictionary(); propertyBag = new Dictionary <string, object>(); flash = new Flash(); session = new Dictionary <string, object>(); requestParams = new NameValueCollection(); contextItems = new Dictionary <string, object>(); SetupResult.For(engineContext.Server).Return(server); SetupResult.For(engineContext.Request).Return(request); SetupResult.For(engineContext.Response).Return(response); SetupResult.For(engineContext.CurrentController).Return(controller); SetupResult.For(engineContext.CurrentControllerContext).Return(controllerContext); SetupResult.For(engineContext.Flash).Return(flash); SetupResult.For(engineContext.Session).Return(session); SetupResult.For(engineContext.Items).Return(contextItems); SetupResult.For(request.Params).Return(requestParams); SetupResult.For(controllerContext.LayoutNames).Return(new[] { "default" }); SetupResult.For(controllerContext.Helpers).Return(helpers); SetupResult.For(controllerContext.PropertyBag).Return(propertyBag); SetupResult.For(routingEngine.IsEmpty).Return(true); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); var serviceProvider = mocks.CreateMock <IServiceProvider>(); var viewSourceLoader = new FileAssemblyViewSourceLoader("Views"); SetupResult.For(serviceProvider.GetService(typeof(IViewSourceLoader))).Return(viewSourceLoader); SetupResult.For(serviceProvider.GetService(typeof(ILoggerFactory))).Return(new NullLogFactory()); SetupResult.For(serviceProvider.GetService(typeof(ISparkViewEngine))).Return(null); SetupResult.For(serviceProvider.GetService(typeof(IUrlBuilder))).Return(urlBuilder); SetupResult.For(serviceProvider.GetService(typeof(IViewComponentFactory))).Return(null); mocks.Replay(serviceProvider); SetupResult.For(engineContext.GetService(null)).IgnoreArguments().Do( new Func <Type, object>(serviceProvider.GetService)); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }
public TemplateParserService(string templateDirectory) { viewSourceLoader = new FileAssemblyViewSourceLoader(templateDirectory); standaloneBooViewEngine = new StandaloneBooViewEngine(viewSourceLoader, null); }
public void SetUp() { var en = CultureInfo.CreateSpecificCulture("en"); Thread.CurrentThread.CurrentCulture = en; Thread.CurrentThread.CurrentUICulture = en; Layout = null; PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase); Helpers = new HelperDictionary(); var services = new StubMonoRailServices { UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()), UrlTokenizer = new DefaultUrlTokenizer(), CacheProvider = new StubCacheProvider() }; services.AddService(typeof(ICacheProvider), services.CacheProvider); var urlInfo = new UrlInfo( "example.org", "test", "", "http", 80, "http://test.example.org/test_area/test_controller/test_action.tdd", Area, ControllerName, Action, "tdd", "no.idea"); Response = new StubResponse(); EngineContext = new StubEngineContext(new StubRequest(), Response, services, urlInfo); services.AddService(typeof(IEngineContext), EngineContext); EngineContext.AddService <IEngineContext>(EngineContext); EngineContext.AddService <IUrlBuilder>(services.UrlBuilder); EngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer); EngineContext.AddService <ICacheProvider>(services.CacheProvider); ViewComponentFactory = new DefaultViewComponentFactory(); ViewComponentFactory.Service(EngineContext); EngineContext.AddService <IViewComponentFactory>(ViewComponentFactory); services.AddService(typeof(IViewComponentFactory), ViewComponentFactory); EngineContext.AddService <IViewComponentDescriptorProvider>(new DefaultViewComponentDescriptorProvider()); services.AddService(typeof(IViewComponentDescriptorProvider), EngineContext.GetService <IViewComponentDescriptorProvider>()); ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag }; EngineContext.CurrentControllerContext = ControllerContext; Helpers["formhelper"] = Helpers["form"] = new FormHelper(EngineContext); Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(EngineContext); Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(EngineContext); Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(EngineContext); var viewPath = Path.Combine(ViewSourcePath, "Views"); var loader = new FileAssemblyViewSourceLoader(viewPath); services.ViewSourceLoader = loader; services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); EngineContext.AddService <IViewSourceLoader>(services.ViewSourceLoader); Controller = new BaseTestFixtureController(); Controller.Contextualize(EngineContext, ControllerContext); VelocityViewEngine = new NVelocityViewEngine(); services.AddService(typeof(IViewEngine), VelocityViewEngine); EngineContext.AddService <IViewEngine>(VelocityViewEngine); VelocityViewEngine.SetViewSourceLoader(loader); VelocityViewEngine.Service(services); var viewEngineManager = new DefaultViewEngineManager(); viewEngineManager.RegisterEngineForExtesionLookup(VelocityViewEngine); services.EmailTemplateService = new EmailTemplateService(viewEngineManager); BeforEachTest(); }
public void SetUp() { loader = new FileAssemblyViewSourceLoader(); loader.ViewRootDir = Path.GetFullPath(System.Configuration.ConfigurationManager.AppSettings["tests.src"]); loader.Service(new TestServiceContainer()); }