public void MethodIdempotency()
        {
            ServiceClass clazz = JsonRpcServices.GetClassFromType(typeof(IdempotencyTestService));

            Assert.IsFalse(clazz.GetMethodByName("NonIdempotentMethod").Idempotent);
            Assert.IsTrue(clazz.GetMethodByName("IdempotentMethod").Idempotent);
        }
        public void MethodDescriptions()
        {
            ServiceClass clazz = JsonRpcServices.GetClassFromType(typeof(TestService));

            Assert.AreEqual(0, clazz.GetMethodByName("Foo").Description.Length);
            Assert.AreEqual(0, clazz.GetMethodByName("Baz").Description.Length);
            Assert.AreEqual(0, clazz.GetMethodByName("Sum").Description.Length);
            Assert.AreEqual("Formats a string.", clazz.GetMethodByName("Format").Description);
        }
        public void ResultTypeIsMethodReturnType()
        {
            ServiceClass clazz = JsonRpcServices.GetClassFromType(typeof(TestService));

            Assert.AreEqual(typeof(void), clazz.GetMethodByName("Foo").ResultType);
            Assert.AreEqual(typeof(void), clazz.GetMethodByName("Baz").ResultType);
            Assert.AreEqual(typeof(int), clazz.GetMethodByName("Sum").ResultType);
            Assert.AreEqual(typeof(string), clazz.GetMethodByName("Format").ResultType);
        }
        public void Invocation()
        {
            ServiceClass clazz   = JsonRpcServices.GetClassFromType(typeof(TestService));
            TestService  service = new TestService();
            object       result  = clazz.GetMethodByName("Sum").Invoke(service, null, new object[] { 2, 3 });

            Assert.AreEqual(5, result);
        }
        public void ParamArray()
        {
            ServiceClass clazz = JsonRpcServices.GetClassFromType(typeof(TestService));

            Assert.IsFalse(clazz.GetMethodByName("Foo").HasParamArray);
            Assert.IsFalse(clazz.GetMethodByName("Baz").HasParamArray);

            Method method;

            Parameter[] parameters;

            method     = clazz.GetMethodByName("Sum");
            parameters = method.GetParameters();
            Assert.IsFalse(method.HasParamArray);
            Assert.IsFalse(parameters[0].IsParamArray);
            Assert.IsFalse(parameters[1].IsParamArray);

            method     = clazz.GetMethodByName("Format");
            parameters = method.GetParameters();
            Assert.IsTrue(method.HasParamArray);
            Assert.IsFalse(parameters[0].IsParamArray);
            Assert.IsTrue(parameters[1].IsParamArray);
        }
        public void Parameters()
        {
            ServiceClass clazz = JsonRpcServices.GetClassFromType(typeof(TestService));

            Parameter[] parameters = clazz.GetMethodByName("Sum").GetParameters();
            Assert.AreEqual(2, parameters.Length);

            Parameter parameter;

            parameter = parameters[0];
            Assert.AreEqual("a", parameter.Name);
            Assert.AreEqual(typeof(int), parameter.ParameterType);
            Assert.AreEqual(0, parameter.Position);

            parameter = parameters[1];
            Assert.AreEqual("b", parameters[1].Name);
            Assert.AreEqual(typeof(int), parameter.ParameterType);
            Assert.AreEqual(1, parameter.Position);
        }