public async Task CanDecodeEncodedData( int testDataSize, int appendBufferSize) { // Mockup var httpSettings = HttpSettings.Default; httpSettings.MaxBodyChunkSize = 1024; var targetStream = new MemoryStream(); var testData = MockData.Bytes(testDataSize, 7); var encoder = new HttpChunkedResponseEncoder( targetStream, TcpSettings.Default, httpSettings ); await encoder.AppendAsync(testData, appendBufferSize); await encoder.CompleteAsync(); // Check targetStream.Position = 0; var decoder = new HttpChunkedRequestBody( new RollbackableStream(targetStream, TcpSettings.Default), new HttpRequestHeader(), TcpSettings.Default ); var result = new MemoryStream(); await decoder.CopyToAsync(result); Assert.True(result.ToArray().SequenceEqual(testData)); }
public async Task WriteDataAsIt(int testSize, int appendBufferSize) { var targetStream = new MemoryStream(); var encoder = new HttpPassthroughResponseEncoder(targetStream, testSize); var testData = MockData.Bytes(testSize, seed: 7); // Begin test await encoder.AppendAsync(testData, appendBufferSize); await encoder.CompleteAsync(); Assert.True(targetStream.ToArray().SequenceEqual(testData)); }