コード例 #1
0
        public void TestResolveMethodStaticOnly()
        {
            var declClass  = typeof(Math);
            var methodName = "Max";
            var args       = new Type[] { typeof(int), typeof(int) };
            var expected   = typeof(Math).GetMethod(methodName, args);

            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));

            args     = new Type[] { typeof(long), typeof(long) };
            expected = typeof(Math).GetMethod(methodName, args);
            args     = new Type[] { typeof(int), typeof(long) };
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));

            args     = new Type[] { typeof(int), typeof(int) };
            expected = typeof(Math).GetMethod(methodName, args);
            args     = new Type[] { typeof(int), typeof(int) };
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));

            args     = new Type[] { typeof(long), typeof(long) };
            expected = typeof(Math).GetMethod(methodName, args);
            args     = new Type[] { typeof(int), typeof(long) };
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));

            args     = new Type[] { typeof(float), typeof(float) };
            expected = typeof(Math).GetMethod(methodName, args);
            args     = new Type[] { typeof(int), typeof(float?) };
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));

            declClass  = typeof(DateTimeHelper);
            methodName = "GetCurrentTimeMillis";
            args       = new Type[0];
            expected   = typeof(DateTimeHelper).GetMethod(methodName, args);
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null));
        }
コード例 #2
0
        public void TestResolveMethodNotFound()
        {
            var allowEventBeanType = new bool[10];
            var declClass          = typeof(String);
            var methodName         = "Trim";

            Type[] args = null;
            try
            {
                MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null);
                Assert.Fail();
            }
            catch (EngineNoSuchMethodException)
            {
                // Expected
            }

            declClass  = typeof(Math);
            methodName = "Moox";
            args       = new Type[] { typeof(int), typeof(int) };
            try
            {
                MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null);
                Assert.Fail();
            }
            catch (EngineNoSuchMethodException)
            {
                // Expected
            }

            methodName = "Max";
            args       = new Type[] { typeof(bool), typeof(bool) };
            try
            {
                MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null);
                Assert.Fail();
            }
            catch (EngineNoSuchMethodException)
            {
                // Expected
            }

            methodName = "Max";
            args       = new Type[] { typeof(int), typeof(int), typeof(bool) };
            try
            {
                MethodResolver.ResolveMethod(declClass, methodName, args, false, null, null);
                Assert.Fail();
            }
            catch (EngineNoSuchMethodException)
            {
                // Expected
            }
        }
コード例 #3
0
        public void TestResolveMethodStaticAndInstance()
        {
            var allowEventBeanType = new bool[10];
            var declClass          = typeof(Math);
            var methodName         = "Max";
            var args     = new Type[] { typeof(int), typeof(int) };
            var expected = typeof(Math).GetMethod(methodName, args);

            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, true, null, null));

            declClass  = typeof(String);
            methodName = "Trim";
            args       = new Type[0];
            expected   = typeof(String).GetMethod(methodName, args);
            Assert.AreEqual(expected, MethodResolver.ResolveMethod(declClass, methodName, args, true, null, null));
        }