public static void Should_Find_Property_Value_Using_Path() { var model = new MyParentObject { Child = new MyChildObject { InnerChild = new MyInnerChildObject { Age = 42 } } }; var value = ReflectionHelper.GetValueByPath(model, typeof(MyParentObject), "Child.InnerChild.Age"); value.ShouldBe(42); }
public static void Should_Find_Property_Using_Path() { var model = new MyParentObject { Child = new MyChildObject { InnerChild = new MyInnerChildObject { Age = 42 } } }; var property = ReflectionHelper.GetPropertyByPath(model, typeof(MyParentObject), "Child.InnerChild.Age"); var propertyInfo = property as PropertyInfo; propertyInfo.ShouldNotBeNull(); propertyInfo.Name.ShouldBe("Age"); propertyInfo.PropertyType.ShouldBe(typeof(Int32)); }