public void Dispose_aborts_pending_read() { var stream = new LoopbackTcpStream(); var readTask = stream.ReadAsync(new byte[1], 0, 1); stream.Dispose(); readTask.Awaiting(t => t).Should().Throw <Exception>(); }
public void Proxy_terminates_with_client_stream_termination() { using (var clientStream = new LoopbackTcpStream()) { var boundUdpClient = new FakeUdpClient(); var relayingUdpClient = new FakeUdpClient(); var timerFactory = new ManuallyInvokedTimerFactory(); var bufferPool = new DebugArrayPool <byte>(); using (var proxy = new UdpProxy( clientStream, new FakeUdpClientFactory(boundUdpClient, relayingUdpClient), new PassthroughInterceptor(), bufferPool, timerFactory, new NullLoggerFactory())) { var task = proxy.RunAsync(CancellationToken.None); clientStream.Dispose(); task.Awaiting(x => x).Should().Throw <Exception>(); } } }