コード例 #1
0
ファイル: NCopContainerTest.cs プロジェクト: arieldeil/NCop
        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);
        }
コード例 #2
0
ファイル: NCopContainerTest.cs プロジェクト: arieldeil/NCop
        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);
        }
コード例 #3
0
ファイル: NCopContainerTest.cs プロジェクト: arieldeil/NCop
        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);
        }
コード例 #4
0
 public void Dispose()
 {
     container.Dispose();
 }
コード例 #5
0
ファイル: NCopContainerTest.cs プロジェクト: sagifogel/NCop
        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);
        }
コード例 #6
0
ファイル: NCopContainerTest.cs プロジェクト: sagifogel/NCop
        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);
        }
コード例 #7
0
ファイル: NCopContainerTest.cs プロジェクト: sagifogel/NCop
        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);
        }