public void CanSetDefaultLifetimeManagerToAlwaysNew() { var lifetime = new AlwaysNewLifetime(); iocContainer.UsesDefaultLifetimeManagerOf(lifetime); Verify.That(iocContainer.DefaultLifetimeManager).IsTheSameObjectAs(lifetime); }
public void CanSetDefaultLifetimeManagerToAlwaysNew() { using (var iocContainer = new IocContainer()) { var lifetime = new AlwaysNewLifetime(); iocContainer.UsesDefaultLifetimeManagerOf(lifetime); Verify.That(iocContainer.DefaultLifetimeManager).IsTheSameObjectAs(lifetime); } }
public void AlwayNewLifetimeManagerAlwaysReturnsNewInstance() { var lifetime = new AlwaysNewLifetime(); iocContainer.UsesDefaultLifetimeManagerOf(lifetime); iocContainer.Register<IFoo>(c => new Foo1()); var foo1 = iocContainer.Resolve<IFoo>(); var foo2 = iocContainer.Resolve<IFoo>(); var foo3 = iocContainer.Resolve<IFoo>(); Verify.That(foo1).IsAnInstanceOfType(typeof(IFoo)) .IsNotTheSameObjectAs(foo2) .IsNotTheSameObjectAs(foo3); Verify.That(foo2).IsAnInstanceOfType(typeof(IFoo)) .IsNotTheSameObjectAs(foo3); Verify.That(foo3).IsAnInstanceOfType(typeof(IFoo)); }
public void AlwayNewLifetimeManagerAlwaysReturnsNewInstance() { var lifetime = new AlwaysNewLifetime(); iocContainer.UsesDefaultLifetimeManagerOf(lifetime); iocContainer.Register <IFoo>(c => new Foo1()); var foo1 = iocContainer.Resolve <IFoo>(); var foo2 = iocContainer.Resolve <IFoo>(); var foo3 = iocContainer.Resolve <IFoo>(); Verify.That(foo1).IsAnInstanceOfType(typeof(IFoo)) .IsNotTheSameObjectAs(foo2) .IsNotTheSameObjectAs(foo3); Verify.That(foo2).IsAnInstanceOfType(typeof(IFoo)) .IsNotTheSameObjectAs(foo3); Verify.That(foo3).IsAnInstanceOfType(typeof(IFoo)); }