public void ResolveMethodTwoParamterInheritSame_GetInherit() { MethodInfo methodInfo = typeof(SampleInheritCls).ResolveMethod("GetCount", new Type[] { typeof(int), typeof(string) }); Assert.IsNotNull(methodInfo); Assert.AreEqual("GetCount", methodInfo.Name); Assert.AreEqual(2, methodInfo.GetParameters().Length); Assert.AreEqual(typeof(string), methodInfo.GetParameters()[1].ParameterType); Assert.AreEqual(typeof(int), methodInfo.GetParameters()[0].ParameterType); SampleInheritCls cls = new SampleInheritCls(); string text = (string)methodInfo.Invoke(cls, new object[] { 1, string.Empty }); Assert.AreEqual("SampleInheritCls", text); }
public void GenericResolveMethodOneParamterArgumentInheritSame_One_Int_String() { MethodInfo methodInfo = typeof(SampleInheritCls).ResolveMethod("GetCount", new Type[] { typeof(int) } , new MethodParameter[] { MethodParameter.CreateGeneric <int>(), MethodParameter.Create <string>() }); Assert.IsNotNull(methodInfo); Assert.AreEqual("GetCount", methodInfo.Name); Assert.AreEqual(2, methodInfo.GetParameters().Length); Assert.AreEqual(typeof(int), methodInfo.GetParameters()[0].ParameterType); Assert.AreEqual(typeof(string), methodInfo.GetParameters()[1].ParameterType); SampleInheritCls cls = new SampleInheritCls(); string text = (string)methodInfo.Invoke(cls, new object[] { 1, string.Empty }); Assert.AreEqual("SampleInheritCls", text); }