public void PropertyGetMethodDelegateCacheTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); Func <object, object> reader1 = (Func <object, object>)DynamicHelper.GetPropertyGetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic), typeof(object)); Func <object, object> reader2 = (Func <object, object>)DynamicHelper.GetPropertyGetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic), typeof(object)); Assert.AreSame(reader1, reader2); }
public void PrivatePropertyGetTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); Func <object, int> reader = (Func <object, int>)DynamicHelper.GetPropertyGetterDelegate(typeof(PropertyTestObject).GetProperty("PrivateInt", BindingFlags.Instance | BindingFlags.NonPublic)); int dataRead = (int)reader(data); Assert.AreEqual(data.GetPrivateInt(), dataRead); }
public void InterfacePropertyGetTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); IUser originalUser = data.User; Func <object, IUser> reader = (Func <object, IUser>)DynamicHelper.GetPropertyGetterDelegate(typeof(PropertyTestObject).GetProperty("User")); IUser userRead = reader(data); Assert.AreSame(originalUser, userRead); }
public void SimplePropertyGetTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); string originalID = data.ID; Func <object, string> reader = (Func <object, string>)DynamicHelper.GetPropertyGetterDelegate(typeof(PropertyTestObject).GetProperty("ID")); string idRead = reader(data); Assert.AreEqual(originalID, idRead); }