Ejemplo n.º 1
0
 public void FahClientConnection_TcpConnectionReturnsNullAfterConnectionIsOpenedAndClosed()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000, new MockTcpConnectionFactory()))
     {
         connection.Open();
         Assert.IsNotNull(connection.TcpConnection);
         connection.Close();
         // Act & Assert
         Assert.IsNull(connection.TcpConnection);
     }
 }
Ejemplo n.º 2
0
 public void FahClientConnection_OpenSuccessfullyAndCloseMultipleTimes()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000, new MockTcpConnectionFactory()))
     {
         // Act (Open)
         connection.Open();
         // Act (Close)
         foreach (var _ in Enumerable.Range(0, 3))
         {
             connection.Close();
         }
     }
 }
Ejemplo n.º 3
0
 public void FahClientConnection_OpenSuccessfullyAndClose()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000, new MockTcpConnectionFactory()))
     {
         // Act (Open)
         connection.Open();
         // Assert
         Assert.IsTrue(connection.Connected);
         // Act (Close)
         connection.Close();
         // Assert
         Assert.IsFalse(connection.Connected);
     }
 }
Ejemplo n.º 4
0
 public void FahClientConnection_TcpConnectionReturnsDifferentInstanceEachTimeConnectionIsOpened()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000, new MockTcpConnectionFactory()))
     {
         connection.Open();
         // Act
         var tcpConnection1 = connection.TcpConnection;
         // close and open again
         connection.Close();
         connection.Open();
         // Act
         var tcpConnection2 = connection.TcpConnection;
         // Assert
         Assert.AreNotSame(tcpConnection1, tcpConnection2);
     }
 }
Ejemplo n.º 5
0
 public void FahClientConnection_ReopenConnectionThatWasPreviouslyOpenedAndClosed()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000, new MockTcpConnectionFactory()))
     {
         // Act (Open)
         connection.Open();
         // Assert
         Assert.IsTrue(connection.Connected);
         // Act (Close)
         connection.Close();
         // Assert
         Assert.IsFalse(connection.Connected);
         // Act (Open Again)
         connection.Open();
         // Assert
         Assert.IsTrue(connection.Connected);
     }
 }
Ejemplo n.º 6
0
 private static void CloseConnectionAfter(int millisecondsDelay, FahClientConnection connection)
 {
     Task.Delay(millisecondsDelay).ContinueWith(t => connection.Close());
 }