Esempio n. 1
0
 public void ShouldProvideAccessToInternalNetworkStream()
 {
     using (var client = new TcpClientAdapter("localhost", Port))
     {
         Assert.IsNotNull(client.GetStream());
     }
 }
Esempio n. 2
0
        public void ShouldProvideConnectionStatus()
        {
            using var client = new TcpClientAdapter();

            client.Connect("localhost", Port);

            Assert.IsTrue(client.Connected);

            this.listener.Stop();

            try
            {
                // Since Connected only reports as of the last operation, we must send or receive data to
                // get the state as of now.
                client.GetStream().Write(new byte[0], 0, 0);

                // To deal with reconnection in real scenarios, the resulting IOException should be caught and
                // then attempt a retry with the exact same client.
            }
            catch (IOException)
            {
                //
            }

            Assert.IsFalse(client.Connected);

            this.listener.Start();
        }