static async Task PerformWriteIntoBody( bool endResponseBodyByDisposingIt, HttpSettings httpSettings, MemoryStream senderData, Mock <IHttpResponse> mockHttpResponse, MemoryStream receiverData, int writeBufferSize = 4096) { var body = new HttpResponseBody( receiverData, TcpSettings.Default, httpSettings, mockHttpResponse.Object); await senderData.CopyToAsync(body, writeBufferSize); if (endResponseBodyByDisposingIt) { body.Dispose(); } else { await body.CompleteAsync(); } }
async Task CanUseDisposeAndCompleteTogether() { // Mockup MockUp(10000, out HttpSettings httpSettings, out MemoryStream senderData, out Mock <IHttpResponse> mockHttpResponse, out MemoryStream receiverData, out HttpResponseHeader responseHeader); // Begin test using (var body = new HttpResponseBody( receiverData, TcpSettings.Default, httpSettings, mockHttpResponse.Object)) { await senderData.CopyToAsync(body, 4096); await body.CompleteAsync(); } await VerifyReceivedChunkedMessage(senderData, receiverData); }