[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); }
[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); }
[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); }