/// <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 fieldRule = new EqualityRule <object>(Comparer(), Name); var valueProvider = new ReflectionFieldValueProvider <TParent, object>(Field); var parentRule = new ParentEqualityRule <TParent, object>(valueProvider, fieldRule); return(new[] { parentRule }); }
public void GetValue_gets_field_value(ClassWithAField testClass, int fieldValue) { var field = Reflect.Field <ClassWithAField>(x => x.MyField); var sut = new ReflectionFieldValueProvider <ClassWithAField, int>(field); testClass.MyField = fieldValue; var result = sut.GetValue(testClass); Assert.That(result, Is.EqualTo(fieldValue)); }