Example #1
0
        public void StopsListeningWhenDisposeIsCalled()
        {
            var log      = new MemoryTrace();
            var listener = new ListenerBase(new IpEndpoint(IpAddress.AnyAddress, 3333), log);

            Assert.Equal(0, log.Count);
            listener.Start();
            Assert.True(Wait.UntilTrue(
                            () => log.GetTrace().Contains(MessageLoop <ListenerBase> .StartingLoopMessage)), log.ToString());
            listener.Dispose();
            Assert.True(Wait.UntilTrue(
                            () => log.GetTrace().Contains(MessageLoop <ListenerBase> .StoppingLoopMessage)), log.ToString());
        }
Example #2
0
        public void StopsThreadWhenDisposeIsCalled()
        {
            var log    = new MemoryTrace();
            var client = new Client(new IpEndpoint(IpAddress.LoopbackAddress, 5000), log);

            Assert.Equal(0, log.Count);
            client.Start();
            Assert.True(Wait.UntilTrue(
                            () => log.GetTrace().Contains(MessageLoop <ListenerBase> .StartingLoopMessage)), log.ToString());
            client.Dispose();
            Assert.True(Wait.UntilTrue(
                            () => log.GetTrace().Contains(MessageLoop <ListenerBase> .StoppingLoopMessage)), log.ToString());
        }