public void IsRegistered_Should_Return_False()
        {
            var resolver = new DryIoCDependencyResolver();
            resolver.RegisterType<IFace1, Class1>();
            resolver.RegisterType<IFace1, Class2>();
            resolver.RegisterInstance<IFace1>(new Class3());

            var result = resolver.IsRegistered<Class3>();
            Assert.IsFalse(result);
        }
Example #2
0
        public void IsRegistered_Should_Return_False()
        {
            var resolver = new DryIoCDependencyResolver();

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

            var result = resolver.IsRegistered <Class3>();

            Assert.IsFalse(result);
        }
        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());
        }
Example #4
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());
        }
Example #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());
        }
        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());
        }