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