Hi guys
The first 2 fail but the third one passes???
Cheers
Anthony

//TestCase 1 : Fails
using (WindsorContainer container = new WindsorContainer())
{
    container.Register(
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            Named("Instance").
            ImplementedBy<MyClass>().
            LifeStyle.Transient,
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            ImplementedBy<MyClass>().
            LifeStyle.Singleton
        );

    var singleton = container.Resolve<IMyInterface>();
    var singleton1 = container.Resolve<IMyInterface>();

    var instance = container.Resolve<IMyInterface>("Instance");
    var instance1 = container.Resolve<IMyInterface>("Instance");

    Assert.AreSame(singleton, singleton1);
    Assert.AreNotSame(instance, instance1);
}

//TestCase 2 : Fails
using (WindsorContainer container = new WindsorContainer())
{
    container.Register(
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            Named("Singleton").
            ImplementedBy<MyClass>().
            LifeStyle.Singleton,
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            ImplementedBy<MyClass>().
            LifeStyle.Transient
        );

    var singleton = container.Resolve<IMyInterface>("Singleton");
    var singleton1 = container.Resolve<IMyInterface>("Singleton");

    var instance = container.Resolve<IMyInterface>();
    var instance1 = container.Resolve<IMyInterface>();

    Assert.AreSame(singleton, singleton1);
    Assert.AreNotSame(instance, instance1);
}

//TestCase 3 : Passes
using (WindsorContainer container = new WindsorContainer())
{
    container.Register(
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            Named("Singleton").
            ImplementedBy<MyClass>().
            LifeStyle.Singleton,
        Castle.MicroKernel.Registration.Component.For<IMyInterface>().
            Named("Instance").
            ImplementedBy<MyClass>().
            LifeStyle.Transient
        );

    var singleton = container.Resolve<IMyInterface>("Singleton");
    var singleton1 = container.Resolve<IMyInterface>("Singleton");

    var instance = container.Resolve<IMyInterface>("Instance");
    var instance1 = container.Resolve<IMyInterface>("Instance");

    Assert.AreSame(singleton, singleton1);
    Assert.AreNotSame(instance, instance1);
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to