public void TestPropertyHelper() { var d = new Data { propertyPrimitive = Math.E }; var proxy = new PropertyOrFieldProxy <Data>(_x => _x.propertyPrimitive); var gotten = proxy.Get(d); Assert.AreEqual(d.propertyPrimitive, gotten); }
public void TestFieldHelper() { var d = new Data { fieldPrimitive = 42 }; var proxy = new PropertyOrFieldProxy <Data>(_x => _x.fieldPrimitive); var gotten = proxy.Get(d); Assert.AreEqual(d.fieldPrimitive, gotten); }
public void TestFieldObjectGet() { var d = new Data { fieldObject = "Hi" }; var fi = typeof(Data).GetField("fieldObject"); var proxy = new PropertyOrFieldProxy(fi); var gotten = proxy.Get(d); Assert.AreEqual(d.fieldObject, gotten); }
public void TestFieldPrimitiveGet() { var d = new Data { fieldPrimitive = 7 }; var fi = typeof(Data).GetField("fieldPrimitive"); var proxy = new PropertyOrFieldProxy(fi); var gotten = proxy.Get(d); Assert.AreEqual(d.fieldPrimitive, gotten); }
public void TestPropertyPrimitiveGet() { var d = new Data { propertyPrimitive = Math.PI }; var fi = typeof(Data).GetProperty("propertyPrimitive"); var proxy = new PropertyOrFieldProxy(fi); var gotten = proxy.Get(d); Assert.AreEqual(d.propertyPrimitive, gotten); }
public void TestPropertyObjectGet() { Data firstVal = new Data(); var d = new Data { propertyObject = firstVal }; var fi = typeof(Data).GetProperty("propertyObject"); var proxy = new PropertyOrFieldProxy(fi); var gotten = proxy.Get(d); Assert.AreEqual(d.propertyObject, gotten); }
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); }
public void TestCreateAccessors() { string newVal = "Bye"; var d = new Data { fieldObject = "Hi" }; var fi = typeof(Data).GetField("fieldObject"); (var getter, var setter) = PropertyOrFieldProxy.CreateAccessors(fi); var gotten = getter(d); Assert.AreEqual("Hi", gotten); setter(d, newVal); Assert.AreEqual(newVal, d.fieldObject); }
public void TestNullConstructorParameter_Property() { PropertyInfo pi = null; var _ = new PropertyOrFieldProxy(pi); }
public void TestNullConstructorParameter_Field() { FieldInfo fi = null; var _ = new PropertyOrFieldProxy(fi); }