public void Proxy_terminates_with_dispose() { using (var clientStream = new LoopbackTcpStream()) { var boundUdpClient = new FakeUdpClient(); var relayingUdpClient = new FakeUdpClient(); var timerFactory = new ManuallyInvokedTimerFactory(); var bufferPool = new DebugArrayPool <byte>(); var interceptor = A.Fake <IDatagramInterceptor>(); using (var proxy = new UdpProxy( clientStream, new FakeUdpClientFactory(boundUdpClient, relayingUdpClient), interceptor, bufferPool, timerFactory, new NullLoggerFactory())) { var task = proxy.RunAsync(CancellationToken.None); proxy.Dispose(); task.Awaiting(x => x).Should().Throw <Exception>(); } A.CallTo(() => interceptor.Dispose()).MustHaveHappenedOnceExactly(); } }
public TestContext() { this.ClientStream = new LoopbackTcpStream(); this.BoundUdpClient = new FakeUdpClient(); this.RelayingUdpClient = new FakeUdpClient(); this._timerFactory = new ManuallyInvokedTimerFactory(); this._bufferPool = new DebugArrayPool <byte>(); this.Interceptor = A.Fake <IDatagramInterceptor>(); this.Proxy = new UdpProxy( this.ClientStream, new FakeUdpClientFactory(this.BoundUdpClient, this.RelayingUdpClient), this.Interceptor, this._bufferPool, this._timerFactory, new NullLoggerFactory()); }
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>(); } } }