private ReflectionPropMethodGetter MakeGetter(Type clazz, string methodName) { var method = clazz.GetMethod(methodName, new Type[] { }); ReflectionPropMethodGetter getter = new ReflectionPropMethodGetter(method, null, null); return(getter); }
public void TestGetter() { ReflectionPropMethodGetter getter = MakeGetter(typeof(SupportBean), "GetIntPrimitive"); Assert.AreEqual(10, getter.Get(unitTestBean)); getter = MakeGetter(typeof(SupportBean), "GetTheString"); Assert.AreEqual("a", getter.Get(unitTestBean)); getter = MakeGetter(typeof(SupportBean), "GetDoubleBoxed"); Assert.AreEqual(null, getter.Get(unitTestBean)); }
public void TestPerformance() { ReflectionPropMethodGetter getter = MakeGetter(typeof(SupportBean), "GetIntPrimitive"); log.Info(".testPerformance Starting test"); for (int i = 0; i < 10; i++) // Change to 1E8 for performance testing { int value = getter.Get(unitTestBean).AsInt32(); Assert.AreEqual(10, value); } log.Info(".testPerformance Done test"); }