public void GetValue_WhenPropertyAccessIsSet_UsesThePropertyAccessToAccessTheValue() { var propertyInfo = this.GetPropertyInfo("Product"); var desciption = new PropertyInfoFieldInfo(propertyInfo, (o) => "MyValue"); var expectedValue = "MyValue"; var actualValue = desciption.GetValue(this.data[0]); Assert.AreEqual(expectedValue, actualValue); }
public void SetValue_WhenPropertySetterIsSet_ShouldUpdateTheValue() { var order = new Order(); var propertyInfo = this.GetPropertyInfo("Product"); var desciption = new PropertyInfoFieldInfo(propertyInfo, (o) => "MyValue", (s, e) => ((Order)s).Product = e.ToString()); desciption.SetValue(order, "Some product"); Assert.AreEqual("Some product", order.Product); }
public void Constructor_WhenNullPropertyInfoIsPassed_ThrowsArgumentNullException() { try { var desciption = new PropertyInfoFieldInfo(null, (o) => o); Assert.Fail("ArgumentNullException expected."); } catch (ArgumentNullException) { } }
public void Constructor_WhenNullPropertyAccessIsPassed_ThrowsArgumentNullException() { try { var propertyInfo = this.GetPropertyInfo("Product"); var desciption = new PropertyInfoFieldInfo(propertyInfo, null); Assert.Fail("ArgumentNullException expected."); } catch (ArgumentNullException) { } }