예제 #1
0
        public void TryResolve_NotRegisteredServiceWithMultipuleArguments_DontThrowsRegistrationExceptionAndReturnsNull()
        {
            var container = new NCopContainer(registry => { });
            var instance  = container.TryResolve <string, int, IFoo>("NCop", 9);

            Assert.IsNull(instance);
        }
예제 #2
0
        public void TryResolve_NotRegisteredService_DontThrowsRegistrationExceptionAndReturnsNull()
        {
            var container = new NCopContainer(registry => { });
            var instance  = container.TryResolve <IFoo>();

            Assert.IsNull(instance);
        }
예제 #3
0
        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 TService TryResolve <TService>()
 {
     return(container.TryResolve <TService>());
 }
예제 #5
0
        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
        public void TryResolve_NotRegisteredServiceWithMultipuleArguments_DontThrowsRegistrationExceptionAndReturnsNull() {
            var container = new NCopContainer(registry => { });
            var instance = container.TryResolve<string, int, IFoo>("NCop", 9);

            Assert.IsNull(instance);
        }
예제 #7
0
        public void TryResolve_NotRegisteredService_DontThrowsRegistrationExceptionAndReturnsNull() {
            var container = new NCopContainer(registry => { });
            var instance = container.TryResolve<IFoo>();

            Assert.IsNull(instance);
        }