public void PrivateFieldTest2() { var t = new SubFieldClass(); var m2 = t.Reflection() .Field("m2") .SetValue(230) .Field("m2") .GetValue(); var f2 = t.Reflection() .Field("m2") .FieldInfoType; var m4 = t.Reflection() .Field("m4") .SetValue(456.25) .Field("m4") .GetValue(); var f4 = t.Reflection() .Field("m4") .FieldInfoType; var t2 = t.Reflection() .Return(); Assert.Equal(230, m2); Assert.Equal(456.25, m4); Assert.Equal(t, t2); Assert.Equal("Int32", f2.Name); Assert.Equal("Double", f4.Name); }
public void PublicFieldTest2() { var t = new SubFieldClass(); var m1 = t.Reflection() .Field(x => x.m1) .SetValue("Foo") .Field(x => x.m1) .GetValue(); var f1 = t.Reflection() .Field(x => x.m1) .FieldInfoType; var m3 = t.Reflection() .Field(x => x.m3) .SetValue(987654321) .Field(x => x.m3) .GetValue(); var f3 = t.Reflection() .Field(x => x.m3) .FieldInfoType; var t2 = t.Reflection() .Return(); Assert.Equal("Foo", t.m1); Assert.Equal("Foo", m1); Assert.Equal(987654321, t.m3); Assert.Equal(987654321, m3); Assert.Equal(t, t2); Assert.Equal("String", f1.Name); Assert.Equal("Int64", f3.Name); }