public void GetAccessorFunctionShouldReturnCorrectDelegateForAProperty(ReflectionDelegateFactory sut, SampleObject obj) { var result = sut.GetAccessorFunction(typeof(SampleObject), nameof(SampleObject.ValidProperty)); Assert.Multiple(() => { Assert.That(result.ExpectedType, Is.EqualTo(typeof(string)), "Correct expected type"); Assert.That(() => result.AccessorFunction(obj), Is.EqualTo(obj.ValidProperty), "Delegate gets correct value"); }); }
public void GetAccessorFunctionShouldReturnCorrectDelegateForAField(ReflectionDelegateFactory sut, SampleObject obj, int fieldValue) { obj.ValidField = fieldValue; var result = sut.GetAccessorFunction(typeof(SampleObject), nameof(SampleObject.ValidField)); Assert.Multiple(() => { Assert.That(result.ExpectedType, Is.EqualTo(typeof(int)), "Correct expected type"); Assert.That(() => result.AccessorFunction(obj), Is.EqualTo(fieldValue), "Delegate gets correct value"); }); }
public void GetSetterActionShouldReturnCorrectDelegateForAValidProperty(ReflectionDelegateFactory sut, SampleObject obj, string propertyValue) { var result = sut.GetSetterAction(typeof(SampleObject), nameof(SampleObject.ValidProperty)); result(obj, propertyValue); Assert.That(obj.ValidProperty, Is.EqualTo(propertyValue)); }