From e07d820a2eab4b4f7872177f746225c1535cfea7 Mon Sep 17 00:00:00 2001 From: roelofb Date: Wed, 6 Dec 2006 16:45:13 +0000 Subject: [PATCH] Applied (modified) patch from Ernst Naezer, fixing FACILITIES-66. git-svn-id: https://svn.castleproject.org/svn/castle/trunk@3053 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- .../BugTestCase.cs | 29 ++++++++++++++++++++++ ...ies.ActiveRecordIntegration.Tests-vs2005.csproj | 1 + .../ActiveRecordFacility.cs | 8 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/BugTestCase.cs diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/BugTestCase.cs b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/BugTestCase.cs new file mode 100644 index 000000000..723dc913e --- /dev/null +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/BugTestCase.cs @@ -0,0 +1,29 @@ +namespace Castle.Facilities.ActiveRecordIntegration.Tests +{ + using Castle.Core.Configuration; + using Castle.MicroKernel.Facilities; + using Castle.Windsor; + using NUnit.Framework; + + [TestFixture] + public class BugTestCase : AbstractActiveRecordTest + { + /// + /// + /// + [Test] + [ExpectedException(typeof(FacilityException), + "You need to specify at least one assembly that contains the ActiveRecord classes. For example, MyAssembly" + )] + public void FACILITIES66() + { + container = new WindsorContainer(); + + IConfiguration confignode = new MutableConfiguration("facility"); + confignode.Children.Add(new MutableConfiguration("arfacility")); + container.Kernel.ConfigurationStore.AddFacilityConfiguration("arfacility", confignode); + + container.AddFacility("arfacility", new ActiveRecordFacility()); + } + } +} \ No newline at end of file diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests-vs2005.csproj b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests-vs2005.csproj index 55e8ee172..47d3ce26c 100644 --- a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests-vs2005.csproj +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests-vs2005.csproj @@ -132,6 +132,7 @@ Code + Code diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs index acb5eee6f..3fea6f8fd 100644 --- a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs @@ -57,9 +57,9 @@ namespace Castle.Facilities.ActiveRecordIntegration throw new FacilityException("Sorry, but the ActiveRecord Facility depends on a proper configuration node."); } - ConfigurationCollection assembliyConfigNodes = FacilityConfig.Children["assemblies"].Children; + IConfiguration assemblyConfig = FacilityConfig.Children["assemblies"]; - if (assembliyConfigNodes.Count == 0) + if (assemblyConfig == null || assemblyConfig.Children.Count == 0) { log.FatalError("No assembly specified on AR Facility config."); @@ -67,6 +67,8 @@ namespace Castle.Facilities.ActiveRecordIntegration "the ActiveRecord classes. For example, MyAssembly"); } + ConfigurationCollection assembliyConfigNodes = assemblyConfig.Children; + ArrayList assemblies = new ArrayList(assembliyConfigNodes.Count); foreach(IConfiguration assemblyNode in assembliyConfigNodes) @@ -255,4 +257,4 @@ namespace Castle.Facilities.ActiveRecordIntegration return type; } } -} \ No newline at end of file +} -- 2.11.4.GIT