public async Task DoesNotFlush_UnderlyingStream_OnDisposingWriter() { // Arrange var stream = new TestMemoryStream(); var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); // Act await writer.WriteAsync("Hello"); writer.Dispose(); // Assert Assert.Equal(0, stream.FlushCallCount); Assert.Equal(0, stream.FlushAsyncCallCount); }
public async Task DoesNotDispose_UnderlyingStream_OnDisposingWriter() { // Arrange var stream = new TestMemoryStream(); var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); // Act await writer.WriteAsync("Hello world"); writer.Dispose(); // Assert Assert.Equal(0, stream.DisposeCallCount); }
public async Task FlushesBuffer_OnDispose(int byteLength) { // Arrange var stream = new TestMemoryStream(); var writer = new HttpResponseStreamWriter(stream, Encoding.UTF8); await writer.WriteAsync(new string('a', byteLength)); // Act writer.Dispose(); // Assert Assert.Equal(0, stream.FlushCallCount); Assert.Equal(0, stream.FlushAsyncCallCount); Assert.Equal(byteLength, stream.Length); }