Auto registration appears to be broken when using nested types.  If I
use .BasedOn<T>().WithService.FromInterface() where T is a nested
type, the registration doesn't work.

Here are 2 ms tests that repro the problem.  The first test passes
while the second fails.  This may be the explanation for my previous
message relating to WithService.Self.


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Castle.Windsor;
using Castle.MicroKernel.Registration;

namespace BrokenWindsorNestedTypes
{
    public interface IService { }
    public interface ITestService : IService { }
    public class TestService : ITestService { }

    [TestClass]
    public class AutoRegistrationTests
    {
        public interface INestedService { }
        public interface INestedTestService : INestedService { }
        public class NestedTestService : INestedTestService { }


        [TestMethod]
        public void AutoRegisterWorks()
        {
            var container = new WindsorContainer();
 
container.Register(AllTypes.FromThisAssembly().BasedOn<IService>().WithService.FromInterface());

 
Assert.IsTrue(container.Kernel.HasComponent(typeof(ITestService)));
        }

        [TestMethod]
        public void AutoRegisterWorksWithNestedTypes()
        {
            var container = new WindsorContainer();
 
container.Register(AllTypes.FromThisAssembly().BasedOn<INestedService>().WithService.FromInterface());

 
Assert.IsTrue(container.Kernel.HasComponent(typeof(INestedTestService)));
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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-users?hl=en.

Reply via email to