public void ParseRequests_BatchRequest_Valid() { const string json = "[{\"jsonrpc\": \"2.0\", \"method\": \"one\", \"params\": [\"1\"], \"id\": \"1\"}, {\"jsonrpc\": \"2.0\", \"method\": \"two\", \"params\": [\"2\"], \"id\": \"2\"}]"; DefaultRpcParser parser = new DefaultRpcParser(null); List <RpcRequest> rpcRequests = parser.ParseRequests(json, out bool isBulkRequest); Assert.NotNull(rpcRequests); Assert.Equal(2, rpcRequests.Count); 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); ParserTests.CompareId("2", rpcRequests[1].Id); Assert.Equal("two", rpcRequests[1].Method); Assert.Equal(JsonRpcContants.JsonRpcVersion, rpcRequests[1].JsonRpcVersion); ParserTests.CompareParameters(new object[] { "2" }, rpcRequests[1].Parameters); Assert.True(isBulkRequest); }
public void ParseRequests_BatchRequest_Valid() { const string json = "[{\"jsonrpc\": \"2.0\", \"method\": \"one\", \"params\": [\"1\"], \"id\": \"1\"}, {\"jsonrpc\": \"2.0\", \"method\": \"two\", \"params\": [\"2\"], \"id\": \"2\"}]"; DefaultRpcParser parser = new DefaultRpcParser(null); bool isBulkRequest; List <RpcRequest> rpcRequests = parser.ParseRequests(json, out isBulkRequest); Assert.NotNull(rpcRequests); Assert.Equal(rpcRequests.Count, 2); Assert.Equal(rpcRequests[0].Id, "1"); Assert.Equal(rpcRequests[0].Method, "one"); Assert.Equal(rpcRequests[0].JsonRpcVersion, JsonRpcContants.JsonRpcVersion); Assert.Equal(rpcRequests[0].ParameterList, new object[] { "1" }); Assert.Equal(rpcRequests[1].Id, "2"); Assert.Equal(rpcRequests[1].Method, "two"); Assert.Equal(rpcRequests[1].JsonRpcVersion, JsonRpcContants.JsonRpcVersion); Assert.Equal(rpcRequests[1].ParameterList, new object[] { "2" }); Assert.True(isBulkRequest); }
public void ParseRequests_BatchRequest_Valid() { const string json = "[{\"jsonrpc\": \"2.0\", \"method\": \"one\", \"params\": [\"1\"], \"id\": \"1\"}, {\"jsonrpc\": \"2.0\", \"method\": \"two\", \"params\": [\"2\"], \"id\": \"2\"}]"; DefaultRpcParser parser = new DefaultRpcParser(null, Options.Create(new RpcServerConfiguration())); ParsingResult result = parser.ParseRequests(json); Assert.NotNull(result); Assert.Equal(2, result.RequestCount); Assert.Equal(2, result.Requests.Count); Assert.Equal("1", result.Requests[0].Id); Assert.Equal("one", result.Requests[0].Method); ParserTests.CompareParameters(new object[] { "1" }, result.Requests[0].Parameters); Assert.Equal("2", result.Requests[1].Id); Assert.Equal("two", result.Requests[1].Method); ParserTests.CompareParameters(new object[] { "2" }, result.Requests[1].Parameters); Assert.True(result.IsBulkRequest); }