public void TestFieldPrimitiveSet() { int newVal = 69; var d = new Data { fieldPrimitive = 7 }; var fi = typeof(Data).GetField("fieldPrimitive"); var proxy = new PropertyOrFieldProxy(fi); proxy.Set(d, newVal); Assert.AreEqual(newVal, d.fieldPrimitive); }
public void TestPropertyPrimitiveSet() { double newVal = Math.E; var d = new Data { propertyPrimitive = Math.PI }; var fi = typeof(Data).GetProperty("propertyPrimitive"); var proxy = new PropertyOrFieldProxy(fi); proxy.Set(d, newVal); Assert.AreEqual(newVal, d.propertyPrimitive); }
public void TestFieldObjectSet() { string newVal = "Bye"; var d = new Data { fieldObject = "Hi" }; var fi = typeof(Data).GetField("fieldObject"); var proxy = new PropertyOrFieldProxy(fi); proxy.Set(d, newVal); Assert.AreEqual(newVal, d.fieldObject); }
public void TestPropertyObjectSet() { Data firstVal = new Data(); Data secondVal = new Data(); var d = new Data { propertyObject = firstVal }; var fi = typeof(Data).GetProperty("propertyObject"); var proxy = new PropertyOrFieldProxy(fi); proxy.Set(d, secondVal); Assert.AreEqual(secondVal, d.propertyObject); }