Пример #1
0
        [TestMethod]    // singleton not deferred
        public void ShouldRespectNotDeferredFlag()
        {
            var            pdi = new DependencyInjector();
            InjectionState @is;
            var            rootBean = new AlreadyInstantiated();

            (_, @is) = pdi.CreateAndInjectDependencies(rootBean
                                                       , deferDepedencyInjection: false);
            Assert.IsNotNull(rootBean?.Child);
        }
Пример #2
0
        [TestMethod]    // prototype not deferred
        public void ShouldCreateDependenciesForPrototypeRootObject()
        {
            var            pdi = new DependencyInjector();
            InjectionState @is;
            var            rootBean = new AlreadyInstantiated();

            (_, @is) = pdi.CreateAndInjectDependencies(rootBean
                                                       , rootBeanSpec: new RootBeanSpec(scope: BeanScope.Prototype));
            Assert.IsNotNull(rootBean?.Child);
        }
Пример #3
0
        [TestMethod]    // prototype deferred
        public void ShouldNotWarnOfPrototypeRootObjectWithDeferredFlag()
        {
            var            pdi = new DependencyInjector();
            InjectionState @is;
            var            rootBean = new AlreadyInstantiated();

            (_, @is) = pdi.CreateAndInjectDependencies(rootBean
                                                       , rootBeanSpec: new RootBeanSpec(scope: BeanScope.Prototype), deferDepedencyInjection: true);
            // pointless but we don't warn.
            Assert.IsNull(rootBean?.Child);
        }