public void MethodDelegateCacheTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); Func <object, int, int, int> func1 = (Func <object, int, int, int>)DynamicHelper.GetMethodInvokeDelegate(data.GetType().GetMethod("Add")); Func <object, int, int, int> func2 = (Func <object, int, int, int>)DynamicHelper.GetMethodInvokeDelegate(data.GetType().GetMethod("Add")); Assert.AreSame(func1, func2); }
public void InvokePublicMethodTest() { PropertyTestObject data = PropertyTestObject.PrepareTestData(); Func <object, int, int, int> func = (Func <object, int, int, int>)DynamicHelper.GetMethodInvokeDelegate(data.GetType().GetMethod("Add")); int result = func(data, 3, 4); Assert.AreEqual(7, result); }