public void ShouldReturnNullWhenGetPropertyValueByRecursionFoundNoProperty() { var dummyObject = new EmptyDummy(); var propertyReflection = new PropertyReflection(); var result = propertyReflection.GetPropertyValue(dummyObject, "Doughnut", true); Assert.IsNull(result); }
public void TestInject() { IList <int> list1 = new List <int>(); List <float> list2 = new List <float>(); Test test = new Test(); var dependency = new DependencyContainer(); dependency.Cache(list1); dependency.Cache(list2); dependency.CacheAs <IList <float> >(list2); dependency.Cache(test); dependency.CacheAs <ITest>(test); TypeInjector injector = new TypeInjector(typeof(Dummy)); TypeInjector injector2 = new TypeInjector(typeof(Dummy2), injector); TypeInjector injector3 = new TypeInjector(typeof(EmptyDummy)); var dummy = new Dummy(); var dummy2 = new Dummy2(); var dummy3 = new EmptyDummy(); LogAssert.Expect(LogType.Error, $"TypeInjector.Inject - Injection target's type ({typeof(Dummy2).Name}) does not match the responsible type ({typeof(Dummy).Name})!"); injector.Inject(dummy2, dependency); Assert.IsNull(dummy2.List1); Assert.IsNull(dummy2.List2); Assert.IsNull(dummy2.List3); Assert.IsNull(dummy2.TestClass); Assert.IsNull(dummy2.TestInterface); injector.Inject(dummy, dependency); Assert.AreSame(dummy.TestInterface, test); Assert.AreSame(dummy.List1, list1); Assert.AreSame(dummy.List2, list2); injector2.Inject(dummy2, dependency); Assert.AreSame(dummy2.TestClass, test); Assert.AreSame(dummy2.TestInterface, test); Assert.AreSame(dummy2.List1, list1); Assert.AreSame(dummy2.List2, list2); Assert.AreSame(dummy2.List3, list2); Assert.IsFalse(dummy3.IsCalled); injector3.Inject(dummy3, dependency); Assert.IsTrue(dummy3.IsCalled); }