public void Import_Lazy_with_AllowDefault_Should_not_check_into_Lazy_dependencies_as_well() { var container = new Container().WithMef(); container.Register <IHardDrive, HitachiHardDrive>(); var x = new Computer3(); container.InjectPropertiesAndFields(x); Assert.That(x.HardDrive, Is.Not.Null); // it is not null because the registration of HardDrive is present but its dependencies are not checked yet (cause laziness) Assert.That(x.HardDrive.Value, Is.Null); // it is null because of allow default and we failing to get the dependency - even if dependency is lazy, we still check the registration }
public void Import_Lazy_with_AllowDefault_Should_not_check_into_dependencies() { var container = new Container().WithMef() .With(r => r.WithoutFuncAndLazyWithoutRegistration()); container.Register <IHardDrive, SamsungHardDrive>(); var x = new Computer3(); container.InjectPropertiesAndFields(x); Assert.That(x.HardDrive, Is.Not.Null); // it is not null because the registration of HardDrive is present but its dependencies are not checked yet (cause laziness) Assert.That(x.HardDrive.Value, Is.Null); // it is null because of allow default and we failing to get the dependency }