示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        // 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));
                    }
                }
            }
        }