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); }
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()); }
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); }
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); }