public void Before_each_test()
		{
			viewEngineManager = new DefaultViewEngineManager();
			firstEngine = new FirstEngine();
			viewEngineManager.RegisterEngineForExtesionLookup(firstEngine);
			secondEngine = new SecondEngine();
			viewEngineManager.RegisterEngineForExtesionLookup(secondEngine);
		}
Exemplo n.º 2
0
 public void Before_each_test()
 {
     viewEngineManager = new DefaultViewEngineManager();
     firstEngine       = new FirstEngine();
     viewEngineManager.RegisterEngineForExtesionLookup(firstEngine);
     secondEngine = new SecondEngine();
     viewEngineManager.RegisterEngineForExtesionLookup(secondEngine);
 }
        protected string ProcessViewJS(string templatePath)
        {
            var sw = new StringWriter();

            ControllerContext.LayoutNames          = Layouts;
            EngineContext.CurrentControllerContext = ControllerContext;
            var engineManager = new DefaultViewEngineManager();

            engineManager.RegisterEngineForView(VelocityViewEngine);
            engineManager.RegisterEngineForExtesionLookup((VelocityViewEngine));
            var codeGenerator =
                new JSCodeGenerator(EngineContext.Server,
                                    engineManager,
                                    EngineContext, null, ControllerContext, EngineContext.Services.UrlBuilder);

            IJSGenerator jsGen = new PrototypeGenerator(codeGenerator);

            codeGenerator.JSGenerator = jsGen;

            var info = new JSCodeGeneratorInfo(codeGenerator, jsGen,
                                               new object[] { new ScriptaculousExtension(codeGenerator) },
                                               new object[] { new ScriptaculousExtension(codeGenerator) });

            VelocityViewEngine.GenerateJS(templatePath, sw, info, EngineContext, null, ControllerContext);
            lastOutput = sw.ToString();
            return(lastOutput);
        }
Exemplo n.º 4
0
        public void Init()
        {
            mocks = new MockRepository();

            MockServices services = new MockServices();

            services.ViewSourceLoader = new FileAssemblyViewSourceLoader("Views");
            services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader);

            viewComponentFactory = new DefaultViewComponentFactory();
            viewComponentFactory.Initialize();
            services.AddService(typeof(IViewComponentFactory), viewComponentFactory);
            services.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry);

            controller        = mocks.DynamicMock <IController>();
            engineContext     = new MockEngineContext(new UrlInfo("", "Home", "Index", "/", "castle"));
            controllerContext = new ControllerContext();

            factory = new SparkViewFactory();
            factory.Service(services);

            engineContext.AddService(typeof(IViewComponentFactory), viewComponentFactory);
            engineContext.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry);

            manager = new DefaultViewEngineManager();
            manager.RegisterEngineForExtesionLookup(factory);
            manager.RegisterEngineForView(factory);
        }
Exemplo n.º 5
0
        protected override void Configure()
        {
            factory = new SparkViewFactory();
            factory.Service(serviceProvider);

            manager = new DefaultViewEngineManager();
            manager.Service(serviceProvider);
            serviceProvider.ViewEngineManager = manager;
            serviceProvider.AddService(typeof(IViewEngineManager), manager);

            manager.RegisterEngineForExtesionLookup(factory);
            manager.RegisterEngineForView(factory);
        }
        protected override void Configure()
        {
            var settings = new SparkSettings();

            settings.SetNullBehaviour(NullBehaviour.Strict);
            var sparkViewEngine = new SparkViewEngine(settings);

            serviceProvider.AddService(typeof(ISparkViewEngine), sparkViewEngine);

            factory = new SparkViewFactory();
            factory.Service(serviceProvider);

            manager = new DefaultViewEngineManager();
            manager.Service(serviceProvider);
            serviceProvider.ViewEngineManager = manager;
            serviceProvider.AddService(typeof(IViewEngineManager), manager);

            manager.RegisterEngineForExtesionLookup(factory);
            manager.RegisterEngineForView(factory);
            factory.Service(serviceProvider);
        }
        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();
		}
		protected string ProcessViewJS(string templatePath)
		{
			var sw = new StringWriter();
			ControllerContext.LayoutNames = Layouts;
			EngineContext.CurrentControllerContext = ControllerContext;
			var engineManager = new DefaultViewEngineManager();
			engineManager.RegisterEngineForView(VelocityViewEngine);
			engineManager.RegisterEngineForExtesionLookup((VelocityViewEngine));
			var codeGenerator =
				new JSCodeGenerator(EngineContext.Server,
				                    engineManager,
				                    EngineContext, null, ControllerContext, EngineContext.Services.UrlBuilder);

			IJSGenerator jsGen = new PrototypeGenerator(codeGenerator);

			codeGenerator.JSGenerator = jsGen;

			var info = new JSCodeGeneratorInfo(codeGenerator, jsGen,
			                                   new object[] {new ScriptaculousExtension(codeGenerator)},
			                                   new object[] {new ScriptaculousExtension(codeGenerator)});

			VelocityViewEngine.GenerateJS(templatePath, sw, info, EngineContext, null, ControllerContext);
			lastOutput = sw.ToString();
			return lastOutput;
		}
Exemplo n.º 10
0
        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);
        }