public void ValueOfArrayParameterTest()
        {
            MethodTests obj = new MethodTests();
            object      ret;

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySize));
            Assert.AreEqual(0, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySum));
            Assert.AreEqual(0, ret);

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySize), new int[] { 1, 2, 3 });
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySum), new int[] { 1, 2, 3 });
            Assert.AreEqual(6, ret);

            Dictionary <string, object> param = new Dictionary <string, object>()
            {
                ["array"] = new int[] { 1, 2, 3 }
            };

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySize), param);
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySum), param);
            Assert.AreEqual(6, ret);

            param["array"] = 10;
            ret            = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySize), param);
            Assert.AreEqual(1, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySum), param);
            Assert.AreEqual(10, ret);
        }
        public void ValueOfListParameterTest()
        {
            MethodTests obj = new MethodTests();
            object      ret;

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize));
            Assert.AreEqual(0, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum));
            Assert.AreEqual(0, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), new double[] { 1, 2, 3 });
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), new double[] { 1, 2, 3 });
            Assert.AreEqual(6, ret);

            List <int> lst = new List <int>()
            {
                1, 2, 3
            };
            Dictionary <string, object> param = new Dictionary <string, object>()
            {
                ["list"]  = lst,
                ["array"] = lst,
            };

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), param);
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), param);
            Assert.AreEqual(6, ret);

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySize), param);
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ArraySum), param);
            Assert.AreEqual(6, ret);

            param["list"] = 10;
            ret           = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), param);
            Assert.AreEqual(1, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), param);
            Assert.AreEqual(10, ret);

            param["list"] = new string[] { "1", "2", "3", "a" };
            ret           = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), param);
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), param);
            Assert.AreEqual(6, ret);

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), param["list"]);
            Assert.AreEqual(3, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), param["list"]);
            Assert.AreEqual(6, ret);

            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSize), "1");
            Assert.AreEqual(1, ret);
            ret = ObjectFactory.InvokeMethod(obj, nameof(obj.ListSum), "5");
            Assert.AreEqual(5, ret);
        }
        public void ChangeParameterTest()
        {
            MethodTests         obj        = new MethodTests();
            Type                methodType = typeof(MethodTests);
            MethodInfo          method     = methodType.GetMethod(nameof(MethodTests.ArraySize));
            object              ret;
            MethodInvokeContext context = ObjectFactory.CreateInvokeContext(method);

            ret = context.Invoke(obj);
            Assert.AreEqual(0, ret);

            context.Arguments[0] = new int[] { 1, 2, 3, 4 };
            ret = context.Invoke(obj);
            Assert.AreEqual(4, ret);

            ObjectFactory.ValueMatching += OnValueMatching;
            DirectoryInfo val = (DirectoryInfo)ObjectFactory.InvokeMethod(obj, nameof(obj.TestChange), "D:\\");

            Assert.AreEqual("D:\\", val.FullName);
        }