Exemplo n.º 1
0
        public void OneObjectParameter()
        {
            var o = new TestReturnObject {
                A = "Chen", X = 1806
            };
            var testSerializer   = new TestSerializer(o);
            var testObjectToCall = new TestObjectToCallOneParameter <TestReturnObject, TestReturnObject>(new TestReturnObject {
                A = "Shane", X = 1806
            }, o);
            var className  = testObjectToCall.GetType().Name;
            var method     = testObjectToCall.GetType().GetMethod("CallMethod");
            var methodName = method.Name;

            var dc = new DynamicCall();

            dc.Add(testObjectToCall, method);
            dc.Add(testObjectToCall, method, "testInterfaceName");
            dc.Add(testObjectToCall, method, "testInterfaceName", "weirdMethodName");
            dc.Add(testObjectToCall, method, methodName: "weirdMethodName");

            Assert.AreEqual(dc.Call(className, methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <TestReturnObject>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <TestReturnObject>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <TestReturnObject>(0)));
            Assert.AreEqual(dc.Call(className, "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <TestReturnObject>(0)));
        }
Exemplo n.º 2
0
        public void OneIntParameter()
        {
            var testSerializer   = new TestSerializer(1990);
            var testObjectToCall = new TestObjectToCallOneParameter <int, int>(1806, 1990);
            var className        = testObjectToCall.GetType().Name;
            var method           = testObjectToCall.GetType().GetMethod("CallMethod");
            var methodName       = method.Name;

            var dc = new DynamicCall();

            dc.Add(testObjectToCall, method);
            dc.Add(testObjectToCall, method, "testInterfaceName");
            dc.Add(testObjectToCall, method, "testInterfaceName", "weirdMethodName");
            dc.Add(testObjectToCall, method, methodName: "weirdMethodName");

            Assert.AreEqual(dc.Call(className, methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <int>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <int>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <int>(0)));
            Assert.AreEqual(dc.Call(className, "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <int>(0)));
        }
Exemplo n.º 3
0
        public void OneStringParameter()
        {
            var testSerializer   = new TestSerializer("Grueling");
            var testObjectToCall = new TestObjectToCallOneParameter <string, string>("Shane", "Grueling");
            var className        = testObjectToCall.GetType().Name;
            var method           = testObjectToCall.GetType().GetMethod("CallMethod");
            var methodName       = method.Name;

            var dc = new DynamicCall();

            dc.Add(testObjectToCall, method);
            dc.Add(testObjectToCall, method, "testInterfaceName");
            dc.Add(testObjectToCall, method, "testInterfaceName", "weirdMethodName");
            dc.Add(testObjectToCall, method, methodName: "weirdMethodName");

            Assert.AreEqual(dc.Call(className, methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <string>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", methodName, testSerializer), testObjectToCall.CallMethod(testSerializer.Get <string>(0)));
            Assert.AreEqual(dc.Call("testInterfaceName", "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <string>(0)));
            Assert.AreEqual(dc.Call(className, "weirdMethodName", testSerializer), testObjectToCall.CallMethod(testSerializer.Get <string>(0)));
        }