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 virtual void Init() { mocks = new MockRepository(); var services = new StubMonoRailServices(); services.ViewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); viewComponentFactory = new DefaultViewComponentFactory(); viewComponentFactory.Initialize(); services.AddService(typeof(IViewComponentFactory), viewComponentFactory); services.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); var settings = new SparkSettings(); engine = new SparkViewEngine(settings); services.AddService(typeof(ISparkViewEngine), engine); factory = new SparkViewFactory(); factory.Service(services); controller = MockRepository.GenerateMock<IController>(); controllerContext = new ControllerContext(); var request = new StubRequest(); request.FilePath = ""; var response = new StubResponse(); engineContext = new StubEngineContext(request, response, new UrlInfo("", "Home", "Index", "/", "castle")); engineContext.AddService(typeof(IViewComponentFactory), viewComponentFactory); engineContext.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); }
public virtual void Init() { mocks = new MockRepository(); var services = new StubMonoRailServices(); services.ViewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); viewComponentFactory = new DefaultViewComponentFactory(); viewComponentFactory.Initialize(); services.AddService(typeof(IViewComponentFactory), viewComponentFactory); services.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); var settings = new SparkSettings(); engine = new SparkViewEngine(settings); services.AddService(typeof(ISparkViewEngine), engine); factory = new SparkViewFactory(); factory.Service(services); controller = MockRepository.GenerateMock <IController>(); controllerContext = new ControllerContext(); var request = new StubRequest(); request.FilePath = ""; var response = new StubResponse(); engineContext = new StubEngineContext(request, response, new UrlInfo("", "Home", "Index", "/", "castle")); engineContext.AddService(typeof(IViewComponentFactory), viewComponentFactory); engineContext.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); }
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 void Init() { var settings = new SparkSettings(); var services = new StubMonoRailServices(); services.AddService(typeof(IViewSourceLoader), new FileAssemblyViewSourceLoader("MonoRail.Tests.Views")); services.AddService(typeof(ISparkViewEngine), new SparkViewEngine(settings)); services.AddService(typeof(IControllerDescriptorProvider), services.ControllerDescriptorProvider); _factory = new SparkViewFactory(); _factory.Service(services); }
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() { 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 override void Install(IDictionary stateSaver) { // figure out all paths based on this assembly in the bin dir var assemblyPath = Parent.GetType().Assembly.CodeBase.Replace("file:///", ""); var targetPath = Path.ChangeExtension(assemblyPath, ".Views.dll"); var appBinPath = Path.GetDirectoryName(assemblyPath); var appBasePath = Path.GetDirectoryName(appBinPath); var viewPath = ViewPath; if (string.IsNullOrEmpty(viewPath)) { viewPath = "Views"; } if (!Directory.Exists(Path.Combine(appBasePath, viewPath)) && Directory.Exists(Path.Combine(appBinPath, viewPath))) { appBasePath = appBinPath; } var webFileHack = Path.Combine(appBasePath, "web"); var viewsLocation = Path.Combine(appBasePath, viewPath); if (!string.IsNullOrEmpty(TargetAssemblyFile)) { targetPath = Path.Combine(appBinPath, TargetAssemblyFile); } // this hack enables you to open the web.config as if it was an .exe.config File.Create(webFileHack).Close(); var config = ConfigurationManager.OpenExeConfiguration(webFileHack); File.Delete(webFileHack); // GetSection will try to resolve the "Spark" assembly, which the installutil appdomain needs help finding AppDomain.CurrentDomain.AssemblyResolve += ((sender, e) => Assembly.LoadFile(Path.Combine(appBinPath, e.Name + ".dll"))); var settings = (ISparkSettings)config.GetSection("spark"); var services = new StubMonoRailServices(); services.AddService(typeof(IViewSourceLoader), new FileAssemblyViewSourceLoader(viewsLocation)); services.AddService(typeof(ISparkViewEngine), new SparkViewEngine(settings)); services.AddService(typeof(IControllerDescriptorProvider), services.ControllerDescriptorProvider); var factory = new SparkViewFactory(); factory.Service(services); // And generate all of the known view/master templates into the target assembly var batch = new SparkBatchDescriptor(targetPath); // create entries for controller attributes in the parent installer's assembly batch.FromAssembly(Parent.GetType().Assembly); // and give the containing installer a change to add entries if (DescribeBatch != null) { DescribeBatch(this, new DescribeBatchEventArgs { Batch = batch }); } factory.Precompile(batch); base.Install(stateSaver); }
public override void Install(IDictionary stateSaver) { // figure out all paths based on this assembly in the bin dir var assemblyPath = Parent.GetType().Assembly.CodeBase.Replace("file:///", ""); var targetPath = Path.ChangeExtension(assemblyPath, ".Views.dll"); var appBinPath = Path.GetDirectoryName(assemblyPath); var appBasePath = Path.GetDirectoryName(appBinPath); var viewPath = ViewPath; if (string.IsNullOrEmpty(viewPath)) viewPath = "Views"; if (!Directory.Exists(Path.Combine(appBasePath, viewPath)) && Directory.Exists(Path.Combine(appBinPath, viewPath))) { appBasePath = appBinPath; } var webFileHack = Path.Combine(appBasePath, "web"); var viewsLocation = Path.Combine(appBasePath, viewPath); if (!string.IsNullOrEmpty(TargetAssemblyFile)) targetPath = Path.Combine(appBinPath, TargetAssemblyFile); // this hack enables you to open the web.config as if it was an .exe.config File.Create(webFileHack).Close(); var config = ConfigurationManager.OpenExeConfiguration(webFileHack); File.Delete(webFileHack); // GetSection will try to resolve the "Spark" assembly, which the installutil appdomain needs help finding AppDomain.CurrentDomain.AssemblyResolve += ((sender, e) => Assembly.LoadFile(Path.Combine(appBinPath, e.Name + ".dll"))); var settings = (ISparkSettings)config.GetSection("spark"); var services = new StubMonoRailServices(); services.AddService(typeof(IViewSourceLoader), new FileAssemblyViewSourceLoader(viewsLocation)); services.AddService(typeof(ISparkViewEngine), new SparkViewEngine(settings)); services.AddService(typeof(IControllerDescriptorProvider), services.ControllerDescriptorProvider); var factory = new SparkViewFactory(); factory.Service(services); // And generate all of the known view/master templates into the target assembly var batch = new SparkBatchDescriptor(targetPath); // create entries for controller attributes in the parent installer's assembly batch.FromAssembly(Parent.GetType().Assembly); // and give the containing installer a change to add entries if (DescribeBatch != null) DescribeBatch(this, new DescribeBatchEventArgs { Batch = batch }); factory.Precompile(batch); base.Install(stateSaver); }