Example #1
0
        private static void InitializeConfig(string configName)
        {
            string path = Path.Combine(siteRoot, "web.config");

            if (!File.Exists(path))
            {
                path = Path.Combine(siteRoot, "app.config");

                if (!File.Exists(path))
                {
                    Console.WriteLine("Cannot locate web.config or app.config" + Environment.NewLine + "VCompile is normally run from the bin directory of the website");
                    Environment.Exit(1);
                }
            }

            XmlNode aspViewNode = null;

            using (XmlTextReader reader = new XmlTextReader(path))
            {
                reader.Namespaces = false;
                XmlDocument xml = new XmlDocument();
                xml.Load(reader);
                aspViewNode = xml.SelectSingleNode("/configuration/aspview");
            }

            AspViewConfigurationSection section = new AspViewConfigurationSection();

            options = (AspViewEngineOptions)section.Create(null, null, aspViewNode);
            if (options != null)
            {
                Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");
            }
        }
		public void SetupFixture()
		{
			AspViewEngineOptions options = new AspViewEngineOptions(new AspViewCompilerOptions());
			engine = new AspViewEngine();
			//engine.Initialize(options);
			engineWithTestAccess = engine;
		}
Example #3
0
        private static void InitializeConfig(string configName)
        {
            string path = Path.Combine(siteRoot, "web.config");

            if (!File.Exists(path))
            {
                Console.WriteLine("Cannot locate web.config" + Environment.NewLine +
                                  "VCompile should run from the bin directory of the website");
                Environment.Exit(1);
            }
            XmlNode aspViewNode;

            using (XmlTextReader reader = new XmlTextReader(path))
            {
                reader.Namespaces = false;
                XmlDocument xml = new XmlDocument();
                xml.Load(reader);
                aspViewNode = xml.SelectSingleNode("/configuration/" + configName);
            }

            if (aspViewNode != null)
            {
                AspViewConfigurationSection section = new AspViewConfigurationSection();
                options = (AspViewEngineOptions)section.Create(null, null, aspViewNode);
            }
        }
Example #4
0
        public void SetupFixture()
        {
            AspViewEngineOptions options = new AspViewEngineOptions(new AspViewCompilerOptions());

            engine = new AspViewEngine();
            //engine.Initialize(options);
            engineWithTestAccess = engine;
        }
Example #5
0
 private static void InitializeConfig()
 {
     InitializeConfig("aspView");
     if (options == null)
     {
         InitializeConfig("aspview");
     }
     if (options == null)
     {
         options = new AspViewEngineOptions();
     }
 }
Example #6
0
        private static void InitializeConfig()
        {
            InitializeConfig("aspView");
            if (options == null)
            {
                InitializeConfig("aspview");
            }
            if (options == null)
            {
                options = new AspViewEngineOptions();
            }

            Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");
        }
Example #7
0
        private static AspViewEngineOptions InitializeConfig()
        {
            var config = GetConfigFromAppSettings("aspView")
                         ?? GetConfigFromAppSettings("aspview")
                         ?? GetConfigFromWebConfig("aspView")
                         ?? GetConfigFromWebConfig("aspview");

            var optionsBuilder = new CompilerOptionsBuilder();

            if (config != null)
            {
                optionsBuilder.ApplyConfigurableOverrides(config);
            }

            var options = new AspViewEngineOptions(optionsBuilder.BuildOptions());

            Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");

            return(options);
        }
		public void SetUp()
		{
			string viewPath = Path.Combine(SiteRoot, "Views");
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			MockServices services = new MockServices();
			services.UrlBuilder = new DefaultUrlBuilder(new MockServerUtility(), new MockRoutingEngine());
			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");
			MockEngineContext = new MockEngineContext(new MockRequest(), new MockResponse(), services,
													  urlInfo);
			MockEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			MockEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			MockEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			MockEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			MockEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

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

			ControllerContext = new ControllerContext();
			ControllerContext.Helpers = Helpers;
			ControllerContext.PropertyBag = PropertyBag;
			MockEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(MockEngineContext);
			Helpers["htmlhelper"] = Helpers["html"] = new HtmlHelper(MockEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(MockEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(MockEngineContext);


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

			viewEngine = new AspViewEngine();
			viewEngine.Service(MockEngineContext);
			AspViewEngineOptions options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			string root = AppDomain.CurrentDomain.BaseDirectory;
			root = root.Substring(0, root.LastIndexOf("Bin\\Debug", StringComparison.InvariantCultureIgnoreCase));
			ICompilationContext context = 
				new CompilationContext(
					new DirectoryInfo(root + @"\Bin\Debug"),
					new DirectoryInfo(root),
					new DirectoryInfo(root + @"\RenderingTests\Views"),
					new DirectoryInfo(root));
			viewEngine.Initialize(context, options);
			System.Console.WriteLine("init");

			BeforEachTest();
		}
		public void SetUp()
		{
			var siteRoot = GetSiteRoot();
			var viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");
			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);
			StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			StubEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			StubEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

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

			ControllerContext = new ControllerContext
			{
				Helpers = Helpers, 
				PropertyBag = PropertyBag
			};
			StubEngineContext.CurrentControllerContext = ControllerContext;


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


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

			viewEngine = new AspViewEngine();
			var options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			((IAspViewEngineTestAccess)viewEngine).SetOptions(options);
			ICompilationContext context =
				new CompilationContext(
					new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
					new DirectoryInfo(siteRoot),
					new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
					new DirectoryInfo(siteRoot));

			var compilationContexts = new List<ICompilationContext> { context };
			((IAspViewEngineTestAccess)viewEngine).SetCompilationContext(compilationContexts);
			viewEngine.Service(StubEngineContext);
		}
        public void SetUp()
        {
            var siteRoot = GetSiteRoot();
            var viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");

            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);
            StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            StubEngineContext.AddService <ILoggerFactory>(new ConsoleFactory());
            StubEngineContext.AddService <IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));


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

            ControllerContext = new ControllerContext
            {
                Helpers     = Helpers,
                PropertyBag = PropertyBag
            };
            StubEngineContext.CurrentControllerContext = ControllerContext;


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


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

            viewEngine = new AspViewEngine();
            var options = new AspViewEngineOptions();

            options.CompilerOptions.AutoRecompilation        = true;
            options.CompilerOptions.KeepTemporarySourceFiles = false;
            ((IAspViewEngineTestAccess)viewEngine).SetOptions(options);
            ICompilationContext context =
                new CompilationContext(
                    new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
                    new DirectoryInfo(siteRoot),
                    new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
                    new DirectoryInfo(siteRoot));

            var compilationContexts = new List <ICompilationContext> {
                context
            };

            ((IAspViewEngineTestAccess)viewEngine).SetCompilationContext(compilationContexts);
            viewEngine.Service(StubEngineContext);
        }
Example #11
0
		private static AspViewEngineOptions InitializeConfig()
		{
			var config = GetConfigFromAppSettings("aspView")
			             ?? GetConfigFromAppSettings("aspview")
			                ?? GetConfigFromWebConfig("aspView")
			                   ?? GetConfigFromWebConfig("aspview");

			var optionsBuilder = new CompilerOptionsBuilder();
			if (config != null)
				optionsBuilder.ApplyConfigurableOverrides(config);

			var options = new AspViewEngineOptions(optionsBuilder.BuildOptions());

			Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");

			return options;
		}
Example #12
0
		private static void InitializeConfig(string configName)
		{
			string path = Path.Combine(siteRoot, "web.config");
			if (!File.Exists(path))
			{
				Console.WriteLine("Cannot locate web.config" + Environment.NewLine +
					"VCompile should run from the bin directory of the website");
				Environment.Exit(1);
			}
			XmlNode aspViewNode;
			using (XmlTextReader reader = new XmlTextReader(path))
			{
				reader.Namespaces = false;
				XmlDocument xml = new XmlDocument();
				xml.Load(reader);
				aspViewNode = xml.SelectSingleNode("/configuration/" + configName);
			}

			if (aspViewNode != null)
			{
				AspViewConfigurationSection section = new AspViewConfigurationSection();
				options = (AspViewEngineOptions) section.Create(null, null, aspViewNode);
			}
		}
Example #13
0
		private static void InitializeConfig()
		{
			InitializeConfig("aspView");
			if (options == null)
				InitializeConfig("aspview");
			if (options == null)
				options = new AspViewEngineOptions();

			Console.WriteLine(options.CompilerOptions.Debug ? "Compiling in DEBUG mode" : "");
		}
Example #14
0
        public void SetUp()
        {
            string viewPath = Path.Combine(SiteRoot, "Views");

            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            MockServices services = new MockServices();

            services.UrlBuilder   = new DefaultUrlBuilder(new MockServerUtility(), new MockRoutingEngine());
            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");

            MockEngineContext = new MockEngineContext(new MockRequest(), new MockResponse(), services,
                                                      urlInfo);
            MockEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            MockEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);
            MockEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            MockEngineContext.AddService <ILoggerFactory>(new ConsoleFactory());
            MockEngineContext.AddService <IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));


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

            ControllerContext             = new ControllerContext();
            ControllerContext.Helpers     = Helpers;
            ControllerContext.PropertyBag = PropertyBag;
            MockEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(MockEngineContext);
            Helpers["htmlhelper"]       = Helpers["html"] = new HtmlHelper(MockEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(MockEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(MockEngineContext);


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

            viewEngine = new AspViewEngine();
            viewEngine.Service(MockEngineContext);
            AspViewEngineOptions options = new AspViewEngineOptions();

            options.CompilerOptions.AutoRecompilation        = true;
            options.CompilerOptions.KeepTemporarySourceFiles = false;
            string root = AppDomain.CurrentDomain.BaseDirectory;

            root = root.Substring(0, root.LastIndexOf("Bin\\Debug", StringComparison.InvariantCultureIgnoreCase));
            ICompilationContext context =
                new CompilationContext(
                    new DirectoryInfo(root + @"\Bin\Debug"),
                    new DirectoryInfo(root),
                    new DirectoryInfo(root + @"\RenderingTests\Views"),
                    new DirectoryInfo(root));

            viewEngine.Initialize(context, options);
            System.Console.WriteLine("init");

            BeforEachTest();
        }