Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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>();
                }
            }
        }