コード例 #1
0
        public void Unresolveable_Should_Return_Null()
        {
            var resolver = new DryIoCDependencyResolver();

            var result = resolver.Resolve <IFace1>();

            Assert.IsNull(result);
        }
コード例 #2
0
        public void Array_Injector_Should_Inject_All_Registed_Types()
        {
            var resolver = new DryIoCDependencyResolver();
            resolver.RegisterType<IFace1, Class1>();
            resolver.RegisterType<IFace1, Class2>();
            resolver.RegisterInstance<IFace1>(new Class3());

            //resolver.RegisterType<Class4, Class4>();
            var resolve = resolver.Resolve<Class4>();
            Assert.AreEqual(3, resolve.Ifaces.Count());
            Assert.IsTrue(resolve.Ifaces.OfType<Class1>().Any());
            Assert.IsTrue(resolve.Ifaces.OfType<Class2>().Any());
            Assert.IsTrue(resolve.Ifaces.OfType<Class3>().Any());
        }
コード例 #3
0
        public void Array_Injector_Should_Inject_All_Registed_Types()
        {
            var resolver = new DryIoCDependencyResolver();

            resolver.RegisterType <IFace1, Class1>();
            resolver.RegisterType <IFace1, Class2>();
            resolver.RegisterInstance <IFace1>(new Class3());

            //resolver.RegisterType<Class4, Class4>();
            var resolve = resolver.Resolve <Class4>();

            Assert.AreEqual(3, resolve.Ifaces.Count());
            Assert.IsTrue(resolve.Ifaces.OfType <Class1>().Any());
            Assert.IsTrue(resolve.Ifaces.OfType <Class2>().Any());
            Assert.IsTrue(resolve.Ifaces.OfType <Class3>().Any());
        }
コード例 #4
0
        public void ResolveAll_Should_Return_All_Registed_Types()
        {
            var resolver = new DryIoCDependencyResolver();

            resolver.RegisterType <IFace1, Class1>();
            resolver.RegisterType <IFace1, Class2>();
            resolver.RegisterInstance <IFace1>(new Class3());

            var resolveAll = resolver.ResolveAll <IFace1>();

            Assert.AreEqual(3, resolveAll.Count());
            Assert.IsTrue(resolveAll.OfType <Class1>().Any());
            Assert.IsTrue(resolveAll.OfType <Class2>().Any());
            Assert.IsTrue(resolveAll.OfType <Class3>().Any());

            resolveAll = resolver.Resolve <IFace1[]>();
            Assert.AreEqual(3, resolveAll.Count());
            Assert.IsTrue(resolveAll.OfType <Class1>().Any());
            Assert.IsTrue(resolveAll.OfType <Class2>().Any());
            Assert.IsTrue(resolveAll.OfType <Class3>().Any());
        }
コード例 #5
0
        public void ResolveAll_Should_Return_All_Registed_Types()
        {
            var resolver = new DryIoCDependencyResolver();
            resolver.RegisterType<IFace1, Class1>();
            resolver.RegisterType<IFace1, Class2>();
            resolver.RegisterInstance<IFace1>(new Class3());

            var resolveAll = resolver.ResolveAll<IFace1>();
            Assert.AreEqual(3, resolveAll.Count());
            Assert.IsTrue(resolveAll.OfType<Class1>().Any());
            Assert.IsTrue(resolveAll.OfType<Class2>().Any());
            Assert.IsTrue(resolveAll.OfType<Class3>().Any());

            resolveAll = resolver.Resolve<IFace1[]>();
            Assert.AreEqual(3, resolveAll.Count());
            Assert.IsTrue(resolveAll.OfType<Class1>().Any());
            Assert.IsTrue(resolveAll.OfType<Class2>().Any());
            Assert.IsTrue(resolveAll.OfType<Class3>().Any());
        }
コード例 #6
0
        public void Unresolveable_Should_Return_Null()
        {
            var resolver = new DryIoCDependencyResolver();

            var result = resolver.Resolve<IFace1>();
            Assert.IsNull(result);
        }