User: xtoff
Date: 2010/02/22 01:35 PM

Modified:
 /InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Registration/
  AllTypesTestCase.cs
 /InversionOfControl/trunk/src/Castle.MicroKernel/Registration/Strategies/
  BasedOnDescriptor.cs

Log:
 - fixed bug introduced in previous which although changed code didn't change 
behavior. All If/Unless predicates will be executed and taken into account now 
when registering components.

File Changes:

Directory: /InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Registration/
===============================================================================

File [modified]: AllTypesTestCase.cs
Delta lines: +0 -0
===================================================================

Directory: 
/InversionOfControl/trunk/src/Castle.MicroKernel/Registration/Strategies/
====================================================================================

File [modified]: BasedOnDescriptor.cs
Delta lines: +35 -0
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Registration/AllTypesTestCase.cs
      2010-02-22 20:10:26 UTC (rev 6758)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Registration/AllTypesTestCase.cs
      2010-02-22 20:35:36 UTC (rev 6759)
@@ -225,6 +225,20 @@
                }
 
                [Test]
+               public void 
RegisterAssemblyTypes_MultipleIfCondition_RegisteredInContainer()
+               {
+                       Kernel.Register(AllTypes.Of<ICustomer>()
+                                               
.FromAssembly(Assembly.GetExecutingAssembly())
+                                               .If(t => t.Name.EndsWith("2"))
+                                               .If(t => 
t.FullName.Contains("Chain"))
+                               );
+
+                       IHandler[] handlers = 
Kernel.GetAssignableHandlers(typeof(ICustomer));
+                       Assert.AreEqual(1, handlers.Length);
+                       Assert.AreEqual(typeof(CustomerChain2), 
handlers.Single().ComponentModel.Implementation);
+               }
+
+               [Test]
                public void 
RegisterAssemblyTypes_UnlessCondition_RegisteredInContainer()
                {
                        Kernel.Register(AllTypes.Of<ICustomer>()
@@ -237,6 +251,27 @@
                                
Assert.IsFalse(typeof(CustomerChain1).IsAssignableFrom(handler.ComponentModel.Implementation));
                        }
                }
+
+
+               [Test]
+               public void 
RegisterAssemblyTypes_MultipleUnlessCondition_RegisteredInContainer()
+               {
+                       Kernel.Register(AllTypes.Of<ICustomer>()
+                                               
.FromAssembly(Assembly.GetExecutingAssembly())
+                                               .Unless(t => 
t.Name.EndsWith("2"))
+                                               .Unless(t => 
t.Name.EndsWith("3"))
+                               );
+
+                       var handlers = 
Kernel.GetAssignableHandlers(typeof(ICustomer));
+                       Assert.IsNotEmpty(handlers);
+                       foreach (var handler in handlers)
+                       {
+                               var name = 
handler.ComponentModel.Implementation.Name;
+                               Assert.IsFalse(name.EndsWith("2"));
+                               Assert.IsFalse(name.EndsWith("3"));
+                       }
+               }
+
 #if(!SILVERLIGHT)
                [Test]

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-commits?hl=en.

Reply via email to