public void Should_return_null_if_not_match_anything() { // Arrange var matcher = new MethodMatcher(); var request = new RpcRequest { DeclaringType = typeof(ISomeService).FullName, MethodName = "MethodNotFound", MemberType = MemberTypes.Method, MethodSignature = matcher.GetMethodSignature(new DynamicMethod("MethodNotFound", typeof(void), null, true)) }; // Action var method = matcher.Match<ISomeService>(request); // Assert Assert.IsNull(method); }
public void Should_return_null_if_not_match_anything() { // Arrange var matcher = new MethodMatcher(); var request = new RpcRequest { DeclaringType = typeof(ISomeService).FullName, MethodName = "MethodNotFound", MemberType = MemberTypes.Method, MethodSignature = matcher.GetMethodSignature(new DynamicMethod("MethodNotFound", typeof(void), null, true)) }; // Action var method = matcher.Match <ISomeService>(request); // Assert Assert.IsNull(method); }
public void Should_return_method_info_if_match() { // Arrange var matcher = new MethodMatcher(); var request = new RpcRequest { DeclaringType = typeof(ISomeService).FullName, MethodName = "TryParse", MemberType = MemberTypes.Method, MethodSignature = matcher.GetMethodSignature(typeof(ISomeService).GetMethod("TryParse")) }; // Action var method = matcher.Match<ISomeService>(request); // Assert Assert.IsNotNull(method); }
public void Should_return_method_info_if_match() { // Arrange var matcher = new MethodMatcher(); var request = new RpcRequest { DeclaringType = typeof(ISomeService).FullName, MethodName = "TryParse", MemberType = MemberTypes.Method, MethodSignature = matcher.GetMethodSignature(typeof(ISomeService).GetMethod("TryParse")) }; // Action var method = matcher.Match <ISomeService>(request); // Assert Assert.IsNotNull(method); }
// Generic bases work. // [Test] public void GenericBase() { SR.MethodInfo mi = typeof(Int16).GetMethod("CompareTo", new Type[] { typeof(Int16) }); MethodReference mr1 = m_module.Import(mi); Type[] types = typeof(Int16).GetInterfaces(); foreach (Type t in types) { if (t.IsGenericType) { mi = t.GetMethod("CompareTo"); if (mi != null) { MethodReference mr2 = m_module.Import(mi); // this throws Console.WriteLine(mr1); Console.WriteLine(mr2); Assert.IsTrue(MethodMatcher.Match(mr1, mr2)); } } } }