public void TestReflectionStructPublicPropertyGetAndSet() { var i = new MyTestStruct(10); var publicProperty1 = i.GetStructPropertyValue <MyTestStruct, int>("PublicProperty"); Assert.Equal(10, publicProperty1); i.SetStructPropertyValue("PublicProperty", 15); var publicProperty2 = i.GetStructPropertyValue <MyTestStruct, int>("PublicProperty"); Assert.Equal(15, publicProperty2); }
public void TestReflectionStructPrivatePropertyGetAndSet() { var i = new MyTestStruct(10); const string propertyName = "PublicProperty2"; var privateProperty1 = i.GetStructPropertyValue <MyTestStruct, string>(propertyName); Assert.Equal("nice", privateProperty1); i.SetStructPropertyValue(propertyName, "test2"); var privateProperty2 = i.GetStructPropertyValue <MyTestStruct, string>(propertyName); Assert.Equal("test2", privateProperty2); }
public void TestReflectionStructPrivatePropertyGetAndSet2() { var i = new MyTestStruct(10); const string propertyName = "PrivateProperty"; var privateProperty1 = i.GetStructPropertyValue <MyTestStruct, int>(propertyName); Assert.Equal(10, privateProperty1); i.SetStructPropertyValue(propertyName, 5); var privateProperty2 = i.GetStructPropertyValue <MyTestStruct, int>(propertyName); Assert.Equal(5, privateProperty2); }
public void TestReflectionSetStructPropertyValueBoxed() { var myTestStruct = new MyTestStruct(); myTestStruct.SetStructPropertyValue("PrivateObjectProperty", 123); var boxedValue = myTestStruct.GetStructPropertyValue <MyTestStruct, object>("PrivateObjectProperty"); Assert.Equal(123, boxedValue); }