public void DisposeOfContainer_OfDisposableObjectWhichIsOwnedExternally_ReturnsNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register <Foo>().OwnedExternally(); }); var instance = container.Resolve <Foo>(); Assert.IsFalse(instance.IsDisposed); container.Dispose(); Assert.IsFalse(instance.IsDisposed); }
public void DisposeOfParentContainer_OfDisposableObjectWhichIsOwnedByChildContainer_ReturnsDispsoedIndication() { var parentContainer = new NCopContainer(registry => { }); var childContainer = parentContainer.CreateChildContainer(registry => { registry.Register <Foo>(); }); var instance = childContainer.Resolve <Foo>(); Assert.IsFalse(instance.IsDisposed); parentContainer.Dispose(); Assert.IsFalse(instance.IsDisposed); }
public void DisposeOfContainer_OfDisposableNamedObjectWithAnArgumentWhichIsOwnedExternally_ReturnsTheNamedInstanceWithNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register <IFoo, string>((c, name) => new Foo(name)) .Named("NCop") .OwnedExternally(); }); var instance = container.TryResolve <string, IFoo>("NCop", "NCop") as Foo; container.Dispose(); Assert.IsNotNull(instance); Assert.IsTrue(instance.Name.Equals("NCop")); Assert.IsFalse(instance.IsDisposed); }
public void Dispose() { container.Dispose(); }
public void DisposeOfContainer_OfDisposableNamedObjectWithAnArgumentWhichIsOwnedExternally_ReturnsTheNamedInstanceWithNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register<IFoo, string>((c, name) => new Foo(name)) .Named("NCop") .OwnedExternally(); }); var instance = container.TryResolve<string, IFoo>("NCop", "NCop") as Foo; container.Dispose(); Assert.IsNotNull(instance); Assert.IsTrue(instance.Name.Equals("NCop")); Assert.IsFalse(instance.IsDisposed); }
public void DisposeOfContainer_OfDisposableObjectWhichIsOwnedExternally_ReturnsNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register<Foo>().OwnedExternally(); }); var instance = container.Resolve<Foo>(); Assert.IsFalse(instance.IsDisposed); container.Dispose(); Assert.IsFalse(instance.IsDisposed); }
public void DisposeOfParentContainer_OfDisposableObjectWhichIsOwnedByChildContainer_ReturnsDispsoedIndication() { var parentContainer = new NCopContainer(registry => { }); var childContainer = parentContainer.CreateChildContainer(registry => { registry.Register<Foo>(); }); var instance = childContainer.Resolve<Foo>(); Assert.IsFalse(instance.IsDisposed); parentContainer.Dispose(); Assert.IsFalse(instance.IsDisposed); }