예제 #1
0
        public async void CoreSerializeResponseAsyncToStreamWhenStreamIsNull()
        {
            var jsonSample        = EmbeddedResourceManager.GetString("Assets.v2_core_res.json");
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage    = new JsonRpcResponse(0L, 0L);

            await Assert.ThrowsAsync <ArgumentNullException>(() =>
                                                             jsonRpcSerializer.SerializeResponseAsync(jsonRpcMessage, null));
        }
예제 #2
0
        public async void CoreSerializeResponseAsyncToStreamWhenResponseIsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage    = new JsonRpcRequest("m", 0L);

            using (var jsonStream = new MemoryStream())
            {
                await Assert.ThrowsAsync <ArgumentNullException>(() =>
                                                                 jsonRpcSerializer.SerializeResponseAsync(null, jsonStream));
            }
        }
예제 #3
0
        public async void CoreSerializeResponseAsyncToStream()
        {
            var jsonSample        = EmbeddedResourceManager.GetString("Assets.v2_core_res.json");
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage    = new JsonRpcResponse(0L, 0L);

            using (var jsonStream = new MemoryStream())
            {
                await jsonRpcSerializer.SerializeResponseAsync(jsonRpcMessage, jsonStream);

                var jsonResult = Encoding.UTF8.GetString(jsonStream.ToArray());

                CompareJsonStrings(jsonSample, jsonResult);
            }
        }