Exemple #1
0
        public void IsRegistered_Should_Return_True()
        {
            var resolver = new SimpleInjectorDependencyResolver();

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

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

            Assert.IsTrue(result);
        }
        public void Array_Injector_Should_Inject_All_Registed_Types()
        {
            var resolver = new SimpleInjectorDependencyResolver();
            resolver.RegisterType<IFace1, Class1>();
            resolver.RegisterType<IFace1, Class2>();
            resolver.RegisterInstance<IFace1>(new Class3());

            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());
        }
Exemple #3
0
        public void Array_Injector_Should_Inject_All_Registed_Types_As_Enumerable()
        {
            var resolver = new SimpleInjectorDependencyResolver();

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

            var resolve = resolver.Resolve <Class5>();

            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());
        }
Exemple #4
0
        public void ResolveAll_Should_Return_All_Registed_Types()
        {
            var resolver = new SimpleInjectorDependencyResolver();

            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());
        }
        public void ResolveAll_Should_Return_All_Registed_Types()
        {
            var resolver = new SimpleInjectorDependencyResolver();
            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());
        }
        public void IsRegistered_Should_Return_True()
        {
            var resolver = new SimpleInjectorDependencyResolver();
            resolver.RegisterType<IFace1, Class1>();
            resolver.RegisterType<IFace1, Class2>();
            resolver.RegisterInstance<IFace1>(new Class3());

            var result = resolver.IsRegistered<IFace1>();
            Assert.IsTrue(result);
        }