public void ShouldGetNestedValue() { var instance = new Car { Wheels = 4, Motor = new Motor { GearBox = new GearBox { Type = "Auto" } } }; Check.That(instance.GetPropertyValueByName(nameof(Car.Wheels))) .IsEqualTo(4); Check.That(instance.GetPropertyValueByName( nameof(Car.Motor), nameof(Motor.GearBox), nameof(GearBox.Type))) .IsEqualTo("Auto"); }
public void ShouldGetValuesFromList() { var instance = new Car { Doors = new List <Door> { new Door(), new Door { IsOpen = true } } }; Check.That(instance.GetPropertyValueByName("Doors", "1", "IsOpen")) .IsEqualTo(true); }