public async Task WriteAsync_IsPassedToUnderlyingStream_WhenDisableResponseBuffering(bool flushable) { var buffer = new byte[] { 1 }; var memoryStream = new MemoryStream(); var stream = new ResponseCompressionBody(new DefaultHttpContext(), new MockResponseCompressionProvider(flushable), new StreamResponseBodyFeature(memoryStream)); stream.DisableBuffering(); await stream.WriteAsync(buffer, 0, buffer.Length); Assert.Equal(buffer, memoryStream.ToArray()); }
public void BeginWrite_IsPassedToUnderlyingStream_WhenDisableResponseBuffering(bool flushable) { var buffer = new byte[] { 1 }; var memoryStream = new MemoryStream(); var stream = new ResponseCompressionBody(new DefaultHttpContext(), new MockResponseCompressionProvider(flushable), new StreamResponseBodyFeature(memoryStream)); stream.DisableBuffering(); stream.BeginWrite(buffer, 0, buffer.Length, (o) => {}, null); Assert.Equal(buffer, memoryStream.ToArray()); }
public async Task SendFileAsync_IsPassedToUnderlyingStream_WhenDisableResponseBuffering() { var memoryStream = new MemoryStream(); var stream = new ResponseCompressionBody(new DefaultHttpContext(), new MockResponseCompressionProvider(true), new StreamResponseBodyFeature(memoryStream)); stream.DisableBuffering(); var path = "testfile1kb.txt"; await stream.SendFileAsync(path, 0, null, CancellationToken.None); Assert.Equal(File.ReadAllBytes(path), memoryStream.ToArray()); }