示例#1
0
        public void CallWithParamNamesInAltCase()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService());
            string            responseString = server.Process("{ id : 1, method : 'Say', params : { MESSAGE : 'Hello' } }");

            Assert.AreEqual("Hello", JsonRpcServices.GetResult((IDictionary)Parse(responseString)));
        }
示例#2
0
        public void CallIdempotentMethodWithIdempotencyRequired()
        {
            JsonRpcDispatcher server = new JsonRpcDispatcher(new TestService());

            server.RequireIdempotency = true;
            JsonRpcServices.GetResult((IDictionary)Parse(server.Process("{ id : 1, method : 'Idem', params : [] }")));
        }
示例#3
0
        public void PositionNineArgDroppedBug()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService2());
            string            responseString = server.Process("{ id : 1, method : 'Echo', params : { o : 123 } }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            Assert.AreEqual(123, Convert.ToInt32(JsonRpcServices.GetResult(response)));
        }
示例#4
0
        public void CallWithUnknownArgsHarmless()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService());
            string            responseString = server.Process("{ id : 1, method : 'Say', params : { message : 'Hello', bad : 'World' } }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            Assert.AreEqual("Hello", JsonRpcServices.GetResult(response));
        }
示例#5
0
        public void CallWithIntArray()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService());
            string            responseString = server.Process("{ id : 42, method : 'sum', params : [ [ 1, 2, 3, 4, 5 ] ] }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            Assert.AreEqual(15, (int)(JsonNumber)JsonRpcServices.GetResult(response));
        }
示例#6
0
        public void CallWithNamedArgs()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService());
            string            responseString = server.Process("{ id : 42, method : 'replicate', params : { count : 3, text : 'Hello' } }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            object[] result = ((JsonArray)JsonRpcServices.GetResult(response)).ToArray();
            Assert.AreEqual(new string[] { "Hello", "Hello", "Hello" }, result);
        }
示例#7
0
        public void Bug8320()
        {
            //
            // Bug #8320: Parameter at Dispatcher without method are not handeld
            // http://developer.berlios.de/bugs/?func=detailbug&bug_id=8320&group_id=4638
            //

            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService());
            string            responseString = server.Process("{ id : 42, params : [ [ 1, 2, 3, 4, 5 ] ], method : 'sum' }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            Assert.AreEqual(15, (int)(JsonNumber)JsonRpcServices.GetResult(response));
        }
示例#8
0
        public void UnknownRequestMembersSkipped()
        {
            JsonRpcDispatcher server = new JsonRpcDispatcher(new TestService());

            JsonRpcServices.GetResult((IDictionary)Parse(server.Process("{ id : 1, foo : [bar], method : 'Dummy', params : [] }")));
        }
示例#9
0
        public void CallWithPositionalArgs()
        {
            JsonRpcDispatcher server         = new JsonRpcDispatcher(new TestService2());
            string            responseString = server.Process("{ id : 1, method : 'EchoMany', params : { 0:11,1:12,2:13,3:14,4:15,5:16,6:17,7:18,8:19,9:20,10:21,11:22,12:23,13:24,14:25,15:26,16:27,17:28,18:29,19:30,20:31,21:32,22:33,23:34,24:35,25:36 } }");
            IDictionary       response       = (IDictionary)Parse(responseString);

            Assert.AreEqual(new int[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }, JsonRpcServices.GetResult(response, typeof(int[])));
        }