public async void CoreSerializeResponsesAsyncToStreamWhenStreamIsNull() { var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage1 = new JsonRpcResponse(0L, 0L); var jsonRpcMessage2 = new JsonRpcResponse(0L, 1L); var jsonRpcMessages = new[] { jsonRpcMessage1, jsonRpcMessage2 }; await Assert.ThrowsAsync <ArgumentNullException>(() => jsonRpcSerializer.SerializeResponsesAsync(jsonRpcMessages, null)); }
public async void CoreSerializeResponsesAsyncToStreamWhenResponsesIsNull() { var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcRequest("m", 0L); using (var jsonStream = new MemoryStream()) { await Assert.ThrowsAsync <ArgumentNullException>(() => jsonRpcSerializer.SerializeResponsesAsync(null, jsonStream)); } }
public async void CoreSerializeResponsesAsyncToStream() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_core_batch_res.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage1 = new JsonRpcResponse(0L, 0L); var jsonRpcMessage2 = new JsonRpcResponse(0L, 1L); var jsonRpcMessages = new[] { jsonRpcMessage1, jsonRpcMessage2 }; using (var jsonStream = new MemoryStream()) { await jsonRpcSerializer.SerializeResponsesAsync(jsonRpcMessages, jsonStream); var jsonResult = Encoding.UTF8.GetString(jsonStream.ToArray()); CompareJsonStrings(jsonSample, jsonResult); } }