コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }