/// <summary> /// Builds and returns a collection of <see cref="IEqualityRule{T}"/>. /// </summary> /// <returns>The rules.</returns> /// <param name="allBuilders">A collection of all rule-builders.</param> public override IEnumerable <IEqualityRule <TParent> > GetRules(IEnumerable <RuleBuilder <TParent> > allBuilders) { var propertyRule = new EqualityRule <object>(Comparer(), Name); var valueProvider = new ReflectionPropertyValueProvider <TParent, object>(Property); var parentRule = new ParentEqualityRule <TParent, object>(valueProvider, propertyRule); return(new[] { parentRule }); }
public void GetValue_gets_property_value(ClassWithAProperty testClass, int propValue) { var property = Reflect.Property <ClassWithAProperty>(x => x.MyProperty); var sut = new ReflectionPropertyValueProvider <ClassWithAProperty, int>(property); testClass.MyProperty = propValue; var result = sut.GetValue(testClass); Assert.That(result, Is.EqualTo(propValue)); }