1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Configuration
;
22 using Castle
.MonoRail
.Framework
.Configuration
;
24 using NUnit
.Framework
;
27 public class WindsorMonoRailSectionHandlerTestCase
29 String dir
= Path
.Combine(ConfigurationManager
.AppSettings
["tests.src"], "ConfigFiles/");
32 public void SimpleTest()
34 MonoRailConfiguration config
= GetConfig("SimpleTest.xml");
40 public void ComplexTest()
42 MonoRailConfiguration config
= GetConfig("ComplexTest.xml");
45 Assert
.AreEqual( "PhotosDemo", config
.ControllersConfig
.Assemblies
[1] );
49 public void PiComplexTest()
51 MonoRailConfiguration config
= GetConfig("Pi-ComplexTest.xml");
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
));
86 private string GetFullPath(String fileName
)
88 return Path
.Combine(AppDomain
.CurrentDomain
.BaseDirectory
, dir
+ fileName
);