Example #1
0
        public async Task ValidErrorResponseSerialization()
        {
            var config = new RpcServerConfiguration();
            IRpcResponseSerializer serializer = new DefaultRpcResponseSerializer(Options.Create(config));

            const string expectedResponseString = "{\"id\":2,\"jsonrpc\":\"2.0\",\"error\":{\"code\":2,\"message\":\"error\",\"data\":\"data\"}}";
            var          response       = new RpcResponse(2, new RpcError(2, "error", "data"));
            string       responseString = await serializer.SerializeAsync(response);

            Assert.Equal(expectedResponseString, responseString, ignoreCase: false, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true);
        }
Example #2
0
        public async Task ValidResponseSerialization()
        {
            var config = new RpcServerConfiguration();
            IRpcResponseSerializer serializer = new DefaultRpcResponseSerializer(Options.Create(config));

            const string expectedResponseString = "{\"id\":1,\"jsonrpc\":\"2.0\",\"result\":\"result\"}";
            var          response       = new RpcResponse(1, "result");
            string       responseString = await serializer.SerializeAsync(response);

            Assert.Equal(expectedResponseString, responseString, ignoreCase: false, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true);
        }