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

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

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

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

            Assert.IsNull(instance);
        }