Exemple #1
0
        public void PropertySetMethodDelegateCacheTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            var writer1 = (Func <object, int, int>)DynamicHelper.GetPropertySetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic));
            var writer2 = (Func <object, int, int>)DynamicHelper.GetPropertySetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic));

            Assert.AreSame(writer1, writer2);
        }
Exemple #2
0
        public void PrivatePropertySetTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            var writer = (Func <object, int, int>)DynamicHelper.GetPropertySetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic));

            writer(data, 2048);

            Assert.AreEqual(2048, data.GetPrivateInt());
        }
Exemple #3
0
        public void InterfacePropertySetNullTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            var writer = (Func <object, IUser, IUser>)DynamicHelper.GetPropertySetterDelegate(typeof(PropertyTestObject).GetProperty("User"));

            writer(data, null);

            Assert.IsNull(data.User);
        }
Exemple #4
0
        public void InterfacePropertySetUserTest()
        {
            PropertyTestObject data = PropertyTestObject.PrepareTestData();

            var writer = (Func <object, IUser, IUser>)DynamicHelper.GetPropertySetterDelegate(typeof(PropertyTestObject).GetProperty("User"));

            IUser user = TestUser.PrepareTestData();

            writer(data, user);

            Assert.AreSame(data.User, user);
        }