Minor changes to improve testability of helpers
[castle.git] / MonoRail / Castle.MonoRail.WindsorExtension.Tests / WindsorMonoRailSectionHandlerTestCase.cs
blob0eaca691dec087a32618428d708493373035a765
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.WindsorExtension.Tests
17 using System;
18 using System.Configuration;
19 using System.IO;
20 using System.Xml;
22 using Castle.MonoRail.Framework.Configuration;
24 using NUnit.Framework;
26 [TestFixture]
27 public class WindsorMonoRailSectionHandlerTestCase
29 String dir = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "ConfigFiles/");
31 [Test]
32 public void SimpleTest()
34 MonoRailConfiguration config = GetConfig("SimpleTest.xml");
36 AssertCommon(config);
39 [Test, Explicit]
40 public void ComplexTest()
42 MonoRailConfiguration config = GetConfig("ComplexTest.xml");
44 AssertCommon(config);
45 Assert.AreEqual( "PhotosDemo", config.ControllersConfig.Assemblies[1] );
48 [Test, Explicit]
49 public void PiComplexTest()
51 MonoRailConfiguration config = GetConfig("Pi-ComplexTest.xml");
53 AssertCommon(config);
54 Assert.AreEqual( "PhotosDemo", config.ControllersConfig.Assemblies[1] );
57 private static void AssertCommon( MonoRailConfiguration config )
59 Assert.AreEqual( "castleproject.org", config.SmtpConfig.Host);
60 Assert.AreEqual( "secret", config.SmtpConfig.Password);
61 Assert.AreEqual( "JoeDoe", config.SmtpConfig.Username);
62 Assert.AreEqual( "Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine",
63 config.ViewEngineConfig.ViewEngines[0].Engine.FullName );
64 Assert.AreEqual( "MoviesDemo", config.ControllersConfig.Assemblies[0] );
66 Assert.IsTrue( config.ViewEngineConfig.ViewPathRoot.EndsWith("views") );
69 public MonoRailConfiguration GetConfig(string fileName)
71 WindsorMonoRailSectionHandler configHandler = new WindsorMonoRailSectionHandler();
73 XmlDocument configFile = GetXmlDocument(fileName);
75 return configHandler.Create(null, null, configFile) as MonoRailConfiguration;
78 public XmlDocument GetXmlDocument(string fileName)
80 XmlDocument doc = new XmlDocument();
81 doc.Load(GetFullPath(fileName));
83 return doc;
86 private string GetFullPath(String fileName)
88 return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dir + fileName);