public void SetRelativeViewPath_ShouldUseCurrentAppDomainsBaseDirectory() { ViewEngineConfig config = new ViewEngineConfig(); config.SetRelativeViewDirectory("views"); var expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views"); Assert.AreEqual(expected, config.ViewPathRoot); }
public void ShouldProcessAdditonalSourcesElement_IfConfiguringSingleViewEngine() { var configXml = @" <monorail> <controllers> <assembly>Castle.MonoRail.Framework.Tests</assembly> </controllers> <viewEngine viewPathRoot=""" + viewFolder + @"""> <additionalSources> <assembly name=""Castle.MonoRail.Framework.Tests"" namespace=""Castle.MonoRail.Framework.Tests.Content"" /> </additionalSources> </viewEngine> </monorail>"; var doc = new XmlDocument(); doc.LoadXml(configXml); var config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.IsTrue(config.AssemblySources.Count > 0, "additonal sources not loaded"); }
public void ShouldProcessAdditonalPathSourcesElement_IfConfiguringSingleViewEngine() { string configXml = @" <monorail> <controllers> <assembly>Castle.MonoRail.Framework.Tests</assembly> </controllers> <viewEngine viewPathRoot=""" + viewFolder + @"""> <additionalSources> <path location=""" + viewFolder + @""" /> </additionalSources> </viewEngine> </monorail>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(configXml); ViewEngineConfig config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.IsTrue(config.PathSources.Count > 0, "additonal path sources not loaded"); Assert.AreEqual(viewFolder, config.PathSources[0]); }
public void AddViewEngine_CreatesNewEntryInViewEngines() { ViewEngineConfig config = new ViewEngineConfig(); config.AddViewEngine<TestViewEngine>(true); Assert.AreEqual(1, config.ViewEngines.Count); ViewEngineInfo info = config.ViewEngines[0]; Assert.AreEqual(typeof(TestViewEngine), info.Engine); Assert.IsTrue(info.XhtmlRendering); }
public void ShouldProcessAdditionalSourcesElement_IfConfiguringMultipleViewEngines() { string configXml = @" <monorail> <controllers> <assembly>Castle.MonoRail.Framework.Tests</assembly> </controllers> <viewEngines viewPathRoot=""Views""> <add type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" /> <additionalSources> <assembly name=""Castle.MonoRail.Framework.Tests"" namespace=""Castle.MonoRail.Framework.Tests.Content"" /> </additionalSources> </viewEngines> </monorail>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(configXml); ViewEngineConfig config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.IsTrue(config.Sources.Length > 0, "Additional sources not loaded"); }
/// <summary> /// Initializes a new instance of the <see cref="MonoRailConfiguration"/> class. /// </summary> public MonoRailConfiguration() { smtpConfig = new SmtpConfig(); viewEngineConfig = new ViewEngineConfig(); controllersConfig = new ControllersConfig(); viewComponentsConfig = new ViewComponentsConfig(); scaffoldConfig = new ScaffoldConfig(); urlConfig = new UrlConfig(); routingRules = new RoutingRuleCollection(); extensions = new ExtensionEntryCollection(); defaultUrls = new DefaultUrlCollection(); jsGeneratorConfig = new JSGeneratorConfiguration(); jsGeneratorConfig.AddLibrary("prototype-1.5.1", typeof(PrototypeGenerator)) .AddExtension(typeof(CommonJSExtension)) .AddExtension(typeof(ScriptaculousExtension)) .AddExtension(typeof(BehaviourExtension)) .BrowserValidatorIs(typeof(PrototypeWebValidator)) .SetAsDefault(); // old routing support related matchHostNameAndPath = false; excludeAppPath = false; }
public void ShouldUseDirectoryNamedViews_IfNoViewPathRootGiven() { // Multiple view engine config string configXml = @" <monorail> <viewEngines> <add type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" /> </viewEngines> </monorail>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(configXml); ViewEngineConfig config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views"), config.ViewPathRoot); // Single view engine config configXml = @" <monorail> <viewEngine customEngine=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" /> </monorail>"; doc.LoadXml(configXml); config.Deserialize(doc.DocumentElement); Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views"), config.ViewPathRoot); }
public void ConfigureWithSingleViewEngine_Should_Work_For_Backward_Compatibility() { var configXml = @" <monorail> <viewEngine customEngine=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine,Castle.MonoRail.Framework.Tests"" viewPathRoot=""" + viewFolder + @"""/> </monorail>"; var doc = new XmlDocument(); doc.LoadXml(configXml); var config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.AreEqual(1, config.ViewEngines.Count); Assert.IsTrue(config.ViewEngines.Exists(TestViewEngineSpecification)); }
public void ConfigureWithMultipleViewEngines_AssignedEnginesToViewEnginesProperty() { var configXml =@" <monorail> <controllers> <assembly>Castle.MonoRail.Framework.Tests</assembly> </controllers> <viewEngines viewPathRoot=""" + viewFolder + @"""> <add type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" /> <add type=""Castle.MonoRail.Framework.Views.Aspx.WebFormsViewEngine, Castle.MonoRail.Framework"" /> </viewEngines> </monorail>"; var doc = new XmlDocument(); doc.LoadXml(configXml); var config = new ViewEngineConfig(); config.Deserialize(doc.DocumentElement); Assert.AreEqual(2, config.ViewEngines.Count); Assert.IsTrue(config.ViewEngines.Exists(TestViewEngineSpecification)); Assert.IsTrue(config.ViewEngines.Exists(WebFormsViewEngineSpecification)); }