コード例 #1
0
        public static void TestInvokeMethod_IntegerParameterBoxing()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            object[] varParams = { 42 };
            Assert.Equal("42", (string)getMethod(typeof(Co1333Invoke), "ConvertI4ObjToString").Invoke(clsObj, varParams));
        }
コード例 #2
0
        public static void TestInvokeMethod_EnumParameterAndEnumReturnValue()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            object[] vars =
            {
                MyColorEnum.RED
            };

            Assert.Equal(MyColorEnum.GREEN, (MyColorEnum)getMethod(typeof(Co1333Invoke), "GetAndRetMyEnum").Invoke(clsObj, vars));
        }
コード例 #3
0
        public static void TestInvokeMethod_PrimitiveParameters()
        {
            Co1333Invoke clsObj = new Co1333Invoke();
            object[] varParams =
            {
                200,
                100000
            };

            Assert.Equal(100200L, (long)getMethod(typeof(Co1333Invoke), "ReturnI8Sum").Invoke(clsObj, varParams));
        }
コード例 #4
0
        public static void TestInvokeMethod_InheritedStaticOnInstance()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            object[] varParams =
            {
                10,
            };

            Assert.Equal(true, (bool)getMethod(typeof(Co1333_a), "IsEvenStatic").Invoke(clsObj, varParams));
        }
コード例 #5
0
        public static void TestInvokeMethod5()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            Int64        retVal      = 0;
            Int64        expectedVal = Int64.MaxValue;

            mi     = getMethod(typeof(Co1333Invoke), "ReturnLongMax");
            retVal = (Int64)mi.Invoke(clsObj, (Object[])null);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #6
0
        public static void TestInvokeMethod4()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            int          retVal      = 0;
            int          expectedVal = 3;

            mi     = getMethod(typeof(Co1333Invoke), "Int4ReturnThree");
            retVal = (int)mi.Invoke(clsObj, (Object[])null);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #7
0
        public static void TestInvokeMethod4()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            int retVal = 0;
            int expectedVal = 3;

            mi = getMethod(typeof(Co1333Invoke), "Int4ReturnThree");
            retVal = (int)mi.Invoke(clsObj, (Object[])null);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #8
0
        public static void TestInvokeMethod_PrimitiveParameters()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            object[] varParams =
            {
                200,
                100000
            };

            Assert.Equal(100200L, (long)getMethod(typeof(Co1333Invoke), "ReturnI8Sum").Invoke(clsObj, varParams));
        }
コード例 #9
0
        public static void TestInvokeMethod_StaticOnInstanceWithPrimitiveParameters()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            object[] varParams =
            {
                10,
                100
            };

            Assert.Equal(110, (int)getMethod(typeof(Co1333Invoke), "ReturnI4Sum").Invoke(clsObj, varParams));
        }
コード例 #10
0
        public static void TestInvokeMethod3()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            string retVal = "";
            string expectedVal = "42";
            Object[] varParams =
            {
                (int)42
            };

            mi = getMethod(typeof(Co1333Invoke), "ConvertI4ObjToString");
            retVal = (String)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #11
0
        public static void TestInvokeMethod10()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            int          retVal      = 0;
            int          expectedVal = (Int32)MyColorEnum.GREEN;

            Object[] vars = new Object[1];
            vars[0] = (MyColorEnum.RED);

            mi = getMethod(typeof(Co1333Invoke), "GetAndRetMyEnum");

            retVal = (int)mi.Invoke(clsObj, vars);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #12
0
        public static void TestInvokeMethod9()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            bool         retVal      = false;
            bool         expectedVal = true;

            Object[] varParams =
            {
                (10),
            };

            mi     = getMethod(typeof(Co1333_a), "IsEvenStatic");
            retVal = (bool)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #13
0
        public static void TestInvokeMethod3()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            string       retVal      = "";
            string       expectedVal = "42";

            Object[] varParams =
            {
                (int)42
            };

            mi     = getMethod(typeof(Co1333Invoke), "ConvertI4ObjToString");
            retVal = (String)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #14
0
        public static void TestInvokeMethod8()
        {
            MethodInfo   mi          = null;
            Co1333Invoke clsObj      = new Co1333Invoke();
            int          retVal      = 0;
            int          expectedVal = 110;

            Object[] varParams =
            {
                (10),
                (100)
            };

            mi     = getMethod(typeof(Co1333Invoke), "ReturnI4Sum");
            retVal = (int)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #15
0
        public static void TestInvokeMethod_EnumParameterAndEnumReturnValue()
        {
            Co1333Invoke clsObj = new Co1333Invoke();
            object[] vars =
            {
                MyColorEnum.RED
            };

            Assert.Equal(MyColorEnum.GREEN, (MyColorEnum)getMethod(typeof(Co1333Invoke), "GetAndRetMyEnum").Invoke(clsObj, vars));
        }
コード例 #16
0
        public static void TestInvokeMethod9()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            bool retVal = false;
            bool expectedVal = true;
            Object[] varParams =
            {
                ( 10 ),
            };

            mi = getMethod(typeof(Co1333_a), "IsEvenStatic");
            retVal = (bool)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #17
0
        public static void TestInvokeMethod8()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            int retVal = 0;
            int expectedVal = 110;
            Object[] varParams =
            {
                ( 10 ),
                ( 100 )
            };

            mi = getMethod(typeof(Co1333Invoke), "ReturnI4Sum");
            retVal = (int)mi.Invoke(clsObj, varParams);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #18
0
        public static void TestInvokeMethod_NoParametersInt64Return()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            Assert.Equal(Int64.MaxValue, (Int64)getMethod(typeof(Co1333Invoke), "ReturnLongMax").Invoke(clsObj, null));
        }
コード例 #19
0
        public static void TestInvokeMethod_NoParametersInt4Return()
        {
            Co1333Invoke clsObj = new Co1333Invoke();

            Assert.Equal(3, (int)getMethod(typeof(Co1333Invoke), "Int4ReturnThree").Invoke(clsObj, null));
        }
コード例 #20
0
        public static void TestInvokeMethod_StaticOnInstanceWithPrimitiveParameters()
        {
            Co1333Invoke clsObj = new Co1333Invoke();
            object[] varParams =
            {
                10,
                100
            };

            Assert.Equal(110, (int)getMethod(typeof(Co1333Invoke), "ReturnI4Sum").Invoke(clsObj, varParams));
        }
コード例 #21
0
        public static void TestInvokeMethod10()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            int retVal = 0;
            int expectedVal = (Int32)MyColorEnum.GREEN;
            Object[] vars = new Object[1];
            vars[0] = (MyColorEnum.RED);

            mi = getMethod(typeof(Co1333Invoke), "GetAndRetMyEnum");

            retVal = (int)mi.Invoke(clsObj, vars);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #22
0
        public static void TestInvokeMethod5()
        {
            MethodInfo mi = null;
            Co1333Invoke clsObj = new Co1333Invoke();
            Int64 retVal = 0;
            Int64 expectedVal = Int64.MaxValue;

            mi = getMethod(typeof(Co1333Invoke), "ReturnLongMax");
            retVal = (Int64)mi.Invoke(clsObj, (Object[])null);

            Assert.True(retVal.Equals(expectedVal), String.Format("Failed! MethodInfo.Invoke did not return correct result. Expected {0} , Got {1}", expectedVal, retVal));
        }
コード例 #23
0
 public static void TestInvokeMethod_NoParametersInt4Return()
 {
     Co1333Invoke clsObj = new Co1333Invoke();
     Assert.Equal(3, (int)getMethod(typeof(Co1333Invoke), "Int4ReturnThree").Invoke(clsObj, null));
 }
コード例 #24
0
 public static void TestInvokeMethod_IntegerParameterBoxing()
 {
     Co1333Invoke clsObj = new Co1333Invoke();
     object[] varParams = { 42 };
     Assert.Equal("42", (string)getMethod(typeof(Co1333Invoke), "ConvertI4ObjToString").Invoke(clsObj, varParams));
 }
コード例 #25
0
        public static void TestInvokeMethod_InheritedStaticOnInstance()
        {
            Co1333Invoke clsObj = new Co1333Invoke();
            object[] varParams =
            {
                10,
            };

            Assert.Equal(true, (bool)getMethod(typeof(Co1333_a), "IsEvenStatic").Invoke(clsObj, varParams));
        }
コード例 #26
0
 public static void TestInvokeMethod_NoParametersInt64Return()
 {
     Co1333Invoke clsObj = new Co1333Invoke();
     Assert.Equal(Int64.MaxValue, (Int64)getMethod(typeof(Co1333Invoke), "ReturnLongMax").Invoke(clsObj, null));
 }