Exemple #1
0
        public void ParseRequests_Valid(string json, object id, string method, object[] parameters)
        {
            DefaultRpcParser parser = new DefaultRpcParser(null);

            RpcRequest rpcRequest = parser.ParseRequests(json, out bool isBulkRequest).FirstOrDefault();

            Assert.NotNull(rpcRequest);
            ParserTests.CompareId(id, rpcRequest.Id);
            Assert.Equal(method, rpcRequest.Method);
            Assert.Equal(JsonRpcContants.JsonRpcVersion, rpcRequest.JsonRpcVersion);
            ParserTests.CompareParameters(parameters, rpcRequest.Parameters);
            Assert.False(isBulkRequest);
        }
Exemple #2
0
        public void ParseRequests_DateTime_Valid()
        {
            const string     json     = "{\"jsonrpc\": \"2.0\", \"method\": \"datetime\", \"params\": [\"2000-12-15T22:11:03\"], \"id\": 1}";
            DateTime         dateTime = DateTime.Parse("2000-12-15T22:11:03");
            DefaultRpcParser parser   = new DefaultRpcParser(null);

            RpcRequest rpcRequest = parser.ParseRequests(json, out bool isBulkRequest).FirstOrDefault();

            Assert.NotNull(rpcRequest);
            ParserTests.CompareId(1, rpcRequest.Id);
            Assert.Equal("datetime", rpcRequest.Method);
            Assert.Equal(JsonRpcContants.JsonRpcVersion, rpcRequest.JsonRpcVersion);
            ParserTests.CompareParameters(new object[] { dateTime }, rpcRequest.Parameters);
            Assert.False(isBulkRequest);
        }
Exemple #3
0
        public void ParseRequests_SingleBatchRequest_Valid()
        {
            const string json = "[{\"jsonrpc\": \"2.0\", \"method\": \"one\", \"params\": [\"1\"], \"id\": \"1\"}]";

            DefaultRpcParser parser = new DefaultRpcParser(null);

            List <RpcRequest> rpcRequests = parser.ParseRequests(json, out bool isBulkRequest);

            Assert.NotNull(rpcRequests);
            Assert.Single(rpcRequests);
            ParserTests.CompareId("1", rpcRequests[0].Id);
            Assert.Equal("one", rpcRequests[0].Method);
            Assert.Equal(JsonRpcContants.JsonRpcVersion, rpcRequests[0].JsonRpcVersion);
            ParserTests.CompareParameters(new object[] { "1" }, rpcRequests[0].Parameters);
            Assert.True(isBulkRequest);
        }