The below Unit Test fails, and I am looking for a valid reason for it doing so.
interface IFoo { }
class Foo : IFoo { }
class Foo2 : IFoo { }
[TestMethod]
public void LifestyleTest4()
{
WindsorContainer container = new WindsorContainer();
container.Register(Component.For<IFoo>().ImplementedBy<Foo>().Named("foo").LifeStyle.Singleton);
IHandler h = container.Kernel.GetHandler("foo");
Assert.IsTrue(h.ComponentModel.LifestyleType == LifestyleType.Singleton);
bool removed = container.Kernel.RemoveComponent("foo");
Assert.IsTrue(removed);
container.Register(Component.For<IFoo>().ImplementedBy<Foo2>().Named("foo").LifeStyle.Transient);
h = container.Kernel.GetHandler("foo");
//Assert will fail as LifestyleType == Singleton
Assert.IsTrue(h.ComponentModel.LifestyleType == LifestyleType.Transient, "Expected Transient Lifestyle");
}
Even though the component was removed from the container, it appears that a reference to the LifeStyle is maintained by name.
I am using the 2.0 release.
Thanks.