public void ShouldBeAbleToConnectAndReconnectSynchronously() { using var client = new TcpClientAdapter(); Assert.IsFalse(client.Connected); client.Connect("localhost", Port); Assert.IsTrue(client.Connected); client.Connect("localhost", Port); Assert.IsTrue(client.Connected); }
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(); }
public void ShouldProvideAccessToInternalNetworkStream() { using var client = new TcpClientAdapter(); client.Connect("localhost", Port); Assert.IsNotNull(client.GetStream()); }