public void UnderlyingStreamsDisposed() { var stream1 = new ThrowOnDisposeStream(); var stream2 = new ThrowOnDisposeStream(); var mergedStream = stream1.Concat(stream2); Assert.Throws <Exception>(() => mergedStream.Dispose()); }
public async Task DispoingTheRequestBodyDoesNotDisposeClientStreams() { var builder = new WebHostBuilder().Configure(app => { app.Run(async context => { using (var sr = new StreamReader(context.Request.Body)) { await context.Response.WriteAsync(await sr.ReadToEndAsync()); } }); }); var server = new TestServer(builder); var stream = new ThrowOnDisposeStream(); stream.Write(Encoding.ASCII.GetBytes("Hello World")); var response = await server.CreateClient().PostAsync("/", new StreamContent(stream)); Assert.True(response.IsSuccessStatusCode); Assert.Equal("Hello World", await response.Content.ReadAsStringAsync()); }
public void UnderlyingStreamsAreNotDisposedIfFlagSet() { var mergedStream = new ThrowOnDisposeStream().Concat(false, new ThrowOnDisposeStream()); mergedStream.Dispose(); }