1 // Copyright 2004-2008 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
.Windsor
.Tests
.Installer
17 using Castle
.Windsor
.Installer
;
18 using Castle
.Windsor
.Tests
.Components
;
19 using NUnit
.Framework
;
22 public class ConfigurationInstallerTestCase
24 private IWindsorContainer container
;
29 container
= new WindsorContainer();
33 public void InstallComponents_FromAppConfig_ComponentsInstalled()
35 container
.Install(Configuration
.FromAppConfig());
37 Assert
.IsTrue(container
.Kernel
.HasComponent(typeof(ICalcService
)));
38 Assert
.IsTrue(container
.Kernel
.HasComponent("calcservice"));
42 public void InstallComponents_FromXmlFile_ComponentsInstalled()
45 Configuration
.FromXmlFile(
46 ConfigHelper
.ResolveConfigPath("installerconfig.xml")));
48 Assert
.IsTrue(container
.Kernel
.HasComponent(typeof(ICalcService
)));
49 Assert
.IsTrue(container
.Kernel
.HasComponent("calcservice"));
53 public void InstallComponents_FromMultiple_ComponentsInstalled()
56 Configuration
.FromAppConfig(),
57 Configuration
.FromXmlFile(
58 ConfigHelper
.ResolveConfigPath("ignoreprop.xml")),
59 Configuration
.FromXmlFile(
60 ConfigHelper
.ResolveConfigPath("robotwireconfig.xml"))
63 Assert
.IsTrue( container
.Kernel
.HasComponent(typeof(ICalcService
)));
64 Assert
.IsTrue( container
.Kernel
.HasComponent("calcservice"));
65 Assert
.IsTrue(container
.Kernel
.HasComponent(typeof(MailServer
)));
66 Assert
.IsTrue(container
.Kernel
.HasComponent("server"));
67 Assert
.IsTrue(container
.Kernel
.HasComponent(typeof(Robot
)));
68 Assert
.IsTrue(container
.Kernel
.HasComponent("robot"));
72 public void InstallComponents_FromXmlFileWithEnvironment_ComponentsInstalled()
75 Configuration
.FromXmlFile(
76 ConfigHelper
.ResolveConfigPath("Configuration2/env_config.xml"))
80 ComponentWithStringProperty prop
=
81 (ComponentWithStringProperty
)container
.Resolve("component");
83 Assert
.AreEqual("John Doe", prop
.Name
);