Exemplo n.º 1
0
        public override void Init()
        {
            _aspxViewEngine             = new AspNetViewEngine();
            _aspxViewEngine.ViewRootDir = ViewRootDir;
            _aspxViewEngine.Init();

            _nvelocityViewEngine             = new NVelocityViewEngine();
            _nvelocityViewEngine.ViewRootDir = ViewRootDir;
            _nvelocityViewEngine.Init();
        }
        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();
		}