Browse Source

Channel:

* Only send SSH_MSG_CHANNEL_EOF message to remote party when we haven't received a SSH_MSG_CHANNEL_EOF or SSH_MSG_CHANNEL_CLOSE message from the remote party.
* Move logic for sending SSH_MSG_CHANNEL_EOF message from derived classes and client classes into Channel.Close(bool) method.
* Move initialization to ctor.

ChannelSession:
* Avoid leaking session semaphores.

SftpFileStream:
* Modify CanRead, CanWrite and CanSeek to return false when the stream is disposed.
* Modify other public members to throw ObjectDisposedException when the stream is disposed or the SFTP session is no longer open.
* Modify Dispose to only flush the write buffer and/or close the SFTP file handle when the SFTP session is open.
* No longer flush write buffer or close SFTP file handle in finalizer. Fixes issue #2013.

Session:
* Remove CreateClientChannel<T> and CreateServerChannel<T> methods; use specific constructors of channels instead.

SftpClient:
* BufferSize was not used for AppendText(String, Encoding) and Create(String) overloads.

SubsystemSession:
* Added IsOpen property.
* Throw ObjectDisposedException in all public members - except for IsOpen - when the session is disposed.
* Throw InvalidOperationException in all public members - except for Connect and IsOpen - when the session is not open.
* Modify Disconnect to release managed resources that are linked to the connected session.
* Modify Dispose to use Disconnect to managed resources that are linked to the connected session.

Unit tests:
* Added large set of tests for changes listed above.
* Tests for which the code was automatically, and that are not yet correctly implemented, are now marked as Ignore.
* Tests that require a (specifically configured) running SSH server are now marked with test category "integration".
Gert Driesen 11 năm trước cách đây
mục cha
commit
71664e2c93
100 tập tin đã thay đổi với 2239 bổ sung688 xóa
  1. 0 15
      Renci.SshClient/Renci.SshNet.Tests/Classes/AuthenticationMethodTest.cs
  2. 0 93
      Renci.SshClient/Renci.SshNet.Tests/Classes/BaseClientTest.cs
  3. 0 13
      Renci.SshClient/Renci.SshNet.Tests/Classes/ChannelAsyncResultTest.cs
  4. 22 18
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs
  5. 228 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Close_SessionIsConnectedAndChannelIsOpen.cs
  6. 0 13
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest.cs
  7. 182 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Close_SessionIsConnectedAndChannelIsOpen.cs
  8. 0 13
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest.cs
  9. 144 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_Closed.cs
  10. 138 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen.cs
  11. 125 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived.cs
  12. 13 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Disposed_Closed.cs
  13. 114 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_ExceptionWaitingOnOpenConfirmation.cs
  14. 139 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_OnOpenFailureReceived_NoRetriesAvailable.cs
  15. 152 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_OnOpenFailureReceived_RetriesAvalable.cs
  16. 12 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelStub.cs
  17. 7 9
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsNotOpen.cs
  18. 134 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived.cs
  19. 23 12
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofReceived.cs
  20. 7 9
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsNotConnectedAndChannelIsNotOpen.cs
  21. 2 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsNotConnectedAndChannelIsOpen.cs
  22. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_OnClose_Exception.cs
  23. 10 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofNotReceived.cs
  24. 103 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofReceived.cs
  25. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelDataReceived_OnData_Exception.cs
  26. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelEofReceived_OnEof_Exception.cs
  27. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelExtendedDataReceived_OnExtendedData_Exception.cs
  28. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelFailureReceived_OnFailure_Exception.cs
  29. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelRequestReceived_OnRequest_Exception.cs
  30. 2 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelSuccessReceived_OnSuccess_Exception.cs
  31. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelWindowAdjustReceived_OnWindowAdjust_Exception.cs
  32. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionDisconnected_OnDisconnected_Exception.cs
  33. 2 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionDisconnected_SessionIsConnectedAndChannelIsOpen.cs
  34. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionErrorOccurred_OnErrorOccurred_Exception.cs
  35. 12 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelStub.cs
  36. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception.cs
  37. 1 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception.cs
  38. 12 25
      Renci.SshClient/Renci.SshNet.Tests/Classes/CommandAsyncResultTest.cs
  39. 2 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/AsyncResultTest.cs
  40. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/BigIntegerTest.cs
  41. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/DerDataTest.cs
  42. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/HostKeyEventArgsTest.cs
  43. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/ObjectIdentifierTest.cs
  44. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshConnectionExceptionTest.cs
  45. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshDataTest.cs
  46. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshExceptionTest.cs
  47. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Compression/CompressorTest.cs
  48. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Compression/ZlibOpenSshTest.cs
  49. 19 20
      Renci.SshClient/Renci.SshNet.Tests/Classes/ExpectActionTest.cs
  50. 19 20
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest.cs
  51. 9 12
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.NET40.cs
  52. 3 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs
  53. 0 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs
  54. 7 11
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortRemote.NET40.cs
  55. 25 16
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs
  56. 0 44
      Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortTest.cs
  57. 8 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs
  58. 19 9
      Renci.SshClient/Renci.SshNet.Tests/Classes/KeyboardInteractiveConnectionInfoTest.cs
  59. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/MessageEventArgsTest.cs
  60. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelMessageTest.cs
  61. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelOpen/ChannelOpenMessageTest.cs
  62. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelOpenInfoTest.cs
  63. 1 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelRequest/ChannelRequestMessageTest.cs
  64. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/RequestInfoTest.cs
  65. 2 1
      Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/MessageTest.cs
  66. 24 12
      Renci.SshClient/Renci.SshNet.Tests/Classes/NetConfClientTest.cs
  67. 0 10
      Renci.SshClient/Renci.SshNet.Tests/Classes/Netconf/NetConfSessionTest.cs
  68. 23 14
      Renci.SshClient/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs
  69. 11 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs
  70. 49 27
      Renci.SshClient/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs
  71. 8 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs
  72. 20 9
      Renci.SshClient/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs
  73. 50 49
      Renci.SshClient/Renci.SshNet.Tests/Classes/ScpClientTest.cs
  74. 5 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs
  75. 10 8
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
  76. 7 6
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs
  77. 7 6
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs
  78. 13 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs
  79. 8 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs
  80. 7 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs
  81. 7 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs
  82. 7 6
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs
  83. 5 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs
  84. 6 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs
  85. 7 6
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs
  86. 9 7
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs
  87. 9 7
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs
  88. 9 7
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs
  89. 5 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs
  90. 5 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs
  91. 6 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs
  92. 6 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs
  93. 7 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs
  94. 6 3
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs
  95. 7 6
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs
  96. 8 4
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs
  97. 143 5
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs
  98. 8 0
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs
  99. 4 2
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs
  100. 4 2
      Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs

+ 0 - 15
Renci.SshClient/Renci.SshNet.Tests/Classes/AuthenticationMethodTest.cs

@@ -1,15 +0,0 @@
-using Renci.SshNet;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests
-{      
-    /// <summary>
-    ///This is a test class for AuthenticationMethodTest and is intended
-    ///to contain all AuthenticationMethodTest Unit Tests
-    ///</summary>
-    [TestClass()]
-    public class AuthenticationMethodTest : TestBase
-    {
-    }
-}

+ 0 - 93
Renci.SshClient/Renci.SshNet.Tests/Classes/BaseClientTest.cs

@@ -1,93 +0,0 @@
-using Renci.SshNet;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests
-{
-    /// <summary>
-    ///This is a test class for BaseClientTest and is intended
-    ///to contain all BaseClientTest Unit Tests
-    ///</summary>
-    [TestClass()]
-    public class BaseClientTest : TestBase
-    {
-        internal virtual BaseClient CreateBaseClient()
-        {
-            // TODO: Instantiate an appropriate concrete class.
-            BaseClient target = null;
-            return target;
-        }
-
-        /// <summary>
-        ///A test for KeepAliveInterval
-        ///</summary>
-        [TestMethod()]
-        public void KeepAliveIntervalTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value
-            TimeSpan actual;
-            target.KeepAliveInterval = expected;
-            actual = target.KeepAliveInterval;
-            Assert.AreEqual(expected, actual);
-            Assert.Inconclusive("Verify the correctness of this test method.");
-        }
-
-        /// <summary>
-        ///A test for IsConnected
-        ///</summary>
-        [TestMethod()]
-        public void IsConnectedTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            bool actual;
-            actual = target.IsConnected;
-            Assert.Inconclusive("Verify the correctness of this test method.");
-        }
-
-        /// <summary>
-        ///A test for SendKeepAlive
-        ///</summary>
-        [TestMethod()]
-        public void SendKeepAliveTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            target.SendKeepAlive();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-
-        /// <summary>
-        ///A test for Dispose
-        ///</summary>
-        [TestMethod()]
-        public void DisposeTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            target.Dispose();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-
-        /// <summary>
-        ///A test for Disconnect
-        ///</summary>
-        [TestMethod()]
-        public void DisconnectTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            target.Disconnect();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-
-        /// <summary>
-        ///A test for Connect
-        ///</summary>
-        [TestMethod()]
-        public void ConnectTest()
-        {
-            BaseClient target = CreateBaseClient(); // TODO: Initialize to an appropriate value
-            target.Connect();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-    }
-}

+ 0 - 13
Renci.SshClient/Renci.SshNet.Tests/Classes/ChannelAsyncResultTest.cs

@@ -1,13 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classeslasses
-{
-    /// <summary>
-    /// Provides additional information for asynchronous command execution
-    /// </summary>
-    [TestClass]
-    public class CommandAsyncResultTest : TestBase
-    {
-    }
-}

+ 22 - 18
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs

@@ -14,15 +14,15 @@ using Renci.SshNet.Tests.Common;
 namespace Renci.SshNet.Tests.Classes.Channels
 {
     [TestClass]
-    public partial class ChannelDirectTcpipTestTest : TestBase
+    public class ChannelDirectTcpipTestTest : TestBase
     {
         private Mock<ISession> _sessionMock;
         private Mock<IForwardedPort> _forwardedPortMock;
+        private uint _localChannelNumber;
         private uint _localWindowSize;
         private uint _localPacketSize;
         private string _remoteHost;
         private uint _port;
-        private uint _localChannelNumber;
         private uint _remoteWindowSize;
         private uint _remotePacketSize;
         private uint _remoteChannelNumber;
@@ -49,7 +49,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
         [TestMethod]
         public void SocketShouldBeClosedAndBindShouldEndWhenForwardedPortSignalsClosingEvent()
         {
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
                 .Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
@@ -65,8 +64,8 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
                 localPortListener.Connected += socket =>
                     {
-                        var channel = new ChannelDirectTcpip();
-                        channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+                        var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
+                            _localPacketSize);
                         channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
 
                         var closeForwardedPortThread =
@@ -91,13 +90,15 @@ namespace Renci.SshNet.Tests.Classes.Channels
                 var buffer = new byte[16];
                 var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
                 Assert.AreEqual(0, bytesReceived);
+                Assert.IsTrue(client.Connected);
+                // signal to server that we also shut down the socket at our end
+                client.Shutdown(SocketShutdown.Send);
             }
         }
 
         [TestMethod]
         public void SocketShouldBeClosedAndBindShouldEndWhenOnErrorOccurredIsInvoked()
         {
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
                 .Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
@@ -113,8 +114,8 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
                 localPortListener.Connected += socket =>
                 {
-                    var channel = new ChannelDirectTcpip();
-                    channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+                    var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
+                        _localPacketSize);
                     channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
 
                     var signalSessionErrorOccurredThread =
@@ -140,13 +141,15 @@ namespace Renci.SshNet.Tests.Classes.Channels
                 var buffer = new byte[16];
                 var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
                 Assert.AreEqual(0, bytesReceived);
+                Assert.IsTrue(client.Connected);
+                // signal to server that we also shut down the socket at our end
+                client.Shutdown(SocketShutdown.Send);
             }
         }
 
         [TestMethod]
         public void SocketShouldBeClosedAndEofShouldBeSentToServerWhenClientShutsDownSocket()
         {
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
                 .Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
@@ -181,21 +184,22 @@ namespace Renci.SshNet.Tests.Classes.Channels
                 localPortListener.Start();
 
                 localPortListener.Connected += socket =>
-                {
-                    channel = new ChannelDirectTcpip();
-                    channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
-                    channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
-                    channel.Bind();
-                    channel.Close();
+                    {
+                        channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
+                            _localPacketSize);
+                        channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
+                        channel.Bind();
+                        channel.Close();
 
-                    handler = socket;
+                        handler = socket;
 
-                    channelBindFinishedWaitHandle.Set();
-                };
+                        channelBindFinishedWaitHandle.Set();
+                    };
 
                 var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                 client.Connect(localPortEndPoint);
                 client.Shutdown(SocketShutdown.Send);
+                Assert.IsFalse(client.Connected);
 
                 channelBindFinishedWaitHandle.WaitOne();
 

+ 228 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Close_SessionIsConnectedAndChannelIsOpen.cs

@@ -0,0 +1,228 @@
+using System;
+using System.Globalization;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Messages.Connection;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelDirectTcpipTest_Close_SessionIsConnectedAndChannelIsOpen
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IForwardedPort> _forwardedPortMock;
+        private ChannelDirectTcpip _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private uint _remoteChannelNumber;
+        private string _remoteHost;
+        private uint _port;
+        private AsyncSocketListener _listener;
+        private EventWaitHandle _channelBindFinishedWaitHandle;
+        private EventWaitHandle _clientReceivedFinishedWaitHandle;
+        private Socket _client;
+        private Exception _channelException;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        [TestCleanup]
+        public void CleanUp()
+        {
+            if (_client != null)
+            {
+                _client.Dispose();
+                _client = null;
+            }
+
+            if (_listener != null)
+            {
+                _listener.Stop();
+                _listener = null;
+            }
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _localWindowSize = (uint) random.Next(2000, 3000);
+            _localPacketSize = (uint) random.Next(1000, 2000);
+            _remoteHost = random.Next().ToString(CultureInfo.InvariantCulture);
+            _port = (uint) random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort);
+            _channelBindFinishedWaitHandle = new ManualResetEvent(false);
+            _clientReceivedFinishedWaitHandle = new ManualResetEvent(false);
+            _channelException = null;
+
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(100, 200);
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelOpenMessage>(m => AssertExpectedMessage(m))));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelOpenConfirmationReceived += null,
+                            new MessageEventArgs<ChannelOpenConfirmationMessage>(
+                                new ChannelOpenConfirmationMessage(
+                                    _localChannelNumber,
+                                    _remoteWindowSize,
+                                    _remotePacketSize,
+                                    _remoteChannelNumber)));
+                        w.WaitOne();
+                    });
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelCloseReceived += null,
+                            new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+                        w.WaitOne();
+                    });
+
+            var localEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
+            _listener = new AsyncSocketListener(localEndpoint);
+            _listener.Connected += socket =>
+                {
+                    try
+                    {
+                        _channel = new ChannelDirectTcpip(
+                            _sessionMock.Object,
+                            _localChannelNumber,
+                            _localWindowSize,
+                            _localPacketSize);
+                        _channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
+                        _channel.Bind();
+                    }
+                    catch (Exception ex)
+                    {
+                        _channelException = ex;
+                    }
+                    finally
+                    {
+                        _channelBindFinishedWaitHandle.Set();
+                    }
+                };
+            _listener.Start();
+
+            _client = new Socket(localEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
+            _client.Connect(localEndpoint);
+
+            var clientReceiveThread = new Thread(
+                () =>
+                    {
+                        var buffer = new byte[16];
+                        var bytesReceived = _client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
+                        if (bytesReceived == 0)
+                        {
+                            //_client.Shutdown(SocketShutdown.Send);
+                            _clientReceivedFinishedWaitHandle.Set();
+                        }
+                    }
+                );
+            clientReceiveThread.Start();
+
+            // give channel time to bind to socket
+            Thread.Sleep(200);
+        }
+
+        private bool AssertExpectedMessage(ChannelOpenMessage channelOpenMessage)
+        {
+            if (channelOpenMessage == null)
+                return false;
+            if (channelOpenMessage.LocalChannelNumber != _localChannelNumber)
+                return false;
+            if (channelOpenMessage.InitialWindowSize != _localWindowSize)
+                return false;
+            if (channelOpenMessage.MaximumPacketSize != _localPacketSize)
+                return false;
+
+            var directTcpipChannelInfo = channelOpenMessage.Info as DirectTcpipChannelInfo;
+            if (directTcpipChannelInfo == null)
+                return false;
+            if (directTcpipChannelInfo.HostToConnect != _remoteHost)
+                return false;
+            if (directTcpipChannelInfo.PortToConnect != _port)
+                return false;
+
+            var clientEndpoint = _client.LocalEndPoint as IPEndPoint;
+            if (clientEndpoint == null)
+                return false;
+            if (directTcpipChannelInfo.OriginatorAddress != clientEndpoint.Address.ToString())
+                return false;
+            if (directTcpipChannelInfo.OriginatorPort != clientEndpoint.Port)
+                return false;
+
+            return true;
+        }
+
+        private void Act()
+        {
+            if (_channel != null)
+            {
+                _channel.Close();
+
+            }
+        }
+
+        [TestMethod]
+        public void BindShouldHaveFinishedWithoutException()
+        {
+            Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
+            Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
+        }
+
+        [TestMethod]
+        public void ClientShouldHaveFinished()
+        {
+            Assert.IsTrue(_clientReceivedFinishedWaitHandle.WaitOne(0));
+        }
+
+        [TestMethod]
+        public void ChannelEofMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ChannelCloseMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+     }
+}

+ 0 - 13
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest.cs

@@ -1,13 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Channels
-{
-    /// <summary>
-    /// Implements "forwarded-tcpip" SSH channel.
-    /// </summary>
-    [TestClass]
-    public class ChannelForwardedTcpipTest : TestBase
-    {
-    }
-}

+ 182 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelForwardedTcpipTest_Close_SessionIsConnectedAndChannelIsOpen.cs

@@ -0,0 +1,182 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Messages.Connection;
+using Renci.SshNet.Tests.Common;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelForwardedTcpipTest_Close_SessionIsConnectedAndChannelIsOpen
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IForwardedPort> _forwardedPortMock;
+        private ChannelForwardedTcpip _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private uint _remoteChannelNumber;
+        private IPEndPoint _remoteEndpoint;
+        private AsyncSocketListener _remoteListener;
+        private EventWaitHandle _channelBindFinishedWaitHandle;
+        private Exception _channelException;
+        private IList<Socket> _connectedRegister;
+        private IList<Socket> _disconnectedRegister;
+        private Thread _channelThread;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        [TestCleanup]
+        public void CleanUp()
+        {
+            if (_remoteListener != null)
+            {
+                _remoteListener.Stop();
+                _remoteListener = null;
+            }
+
+            if (_channelThread != null)
+            {
+                if (_channelThread.IsAlive)
+                    _channelThread.Abort();
+            }
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _localWindowSize = (uint) random.Next(2000, 3000);
+            _localPacketSize = (uint) random.Next(1000, 2000);
+            _remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint) random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint) random.Next(100, 200);
+            _channelBindFinishedWaitHandle = new ManualResetEvent(false);
+            _channelException = null;
+            _connectedRegister = new List<Socket>();
+            _disconnectedRegister = new List<Socket>();
+
+            _remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence).Setup(
+                p => p.SendMessage(
+                    It.Is<ChannelOpenConfirmationMessage>(
+                        m => m.LocalChannelNumber == _remoteChannelNumber
+                             &&
+                             m.InitialWindowSize == _localWindowSize
+                             &&
+                             m.MaximumPacketSize == _localPacketSize
+                             &&
+                             m.RemoteChannelNumber == _localChannelNumber)
+                    ));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                        {
+                            _sessionMock.Raise(
+                                s => s.ChannelCloseReceived += null,
+                                new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+                            w.WaitOne();
+                        });
+
+            _remoteListener = new AsyncSocketListener(_remoteEndpoint);
+            _remoteListener.Connected += socket => _connectedRegister.Add(socket);
+            _remoteListener.Disconnected += socket => _disconnectedRegister.Add(socket);
+            _remoteListener.Start();
+
+            _channel = new ChannelForwardedTcpip(
+                _sessionMock.Object,
+                _localChannelNumber,
+                _localWindowSize,
+                _localPacketSize,
+                _remoteChannelNumber,
+                _remoteWindowSize,
+                _remotePacketSize);
+
+            _channelThread = new Thread(() =>
+                {
+                    try
+                    {
+                        _channel.Bind(_remoteEndpoint, _forwardedPortMock.Object);
+                    }
+                    catch (Exception ex)
+                    {
+                        _channelException = ex;
+                    }
+                    finally
+                    {
+                        _channelBindFinishedWaitHandle.Set();
+                    }
+                });
+            _channelThread.Start();
+
+            // give channel time to bind to remote endpoint
+            Thread.Sleep(100);
+        }
+
+        private void Act()
+        {
+            Console.WriteLine("Before Close=" + Thread.CurrentThread.ManagedThreadId + " | " + DateTime.Now.ToString("O"));
+            _channel.Close();
+            Console.WriteLine("After Close=" + Thread.CurrentThread.ManagedThreadId + " | " + DateTime.Now.ToString("O"));
+        }
+
+        [TestMethod]
+        public void ChannelShouldShutdownSocketToRemoteListener()
+        {
+            Assert.AreEqual(1, _connectedRegister.Count);
+            Assert.AreEqual(1, _disconnectedRegister.Count);
+            Assert.AreSame(_connectedRegister[0], _disconnectedRegister[0]);
+        }
+
+        [TestMethod]
+        public void BindShouldHaveFinishedWithoutException()
+        {
+            Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
+            Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
+        }
+
+        [TestMethod]
+        public void ChannelEofMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ChannelCloseMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 0 - 13
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest.cs

@@ -1,13 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.Channels
-{
-    /// <summary>
-    /// Implements Session SSH channel.
-    /// </summary>
-    [TestClass]
-    public class ChannelSessionTest : TestBase
-    {
-    }
-}

+ 144 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_Closed.cs

@@ -0,0 +1,144 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Close_Closed
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private ChannelSession _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private uint _remoteChannelNumber;
+        private SemaphoreLight _sessionSemaphore;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(2000, 3000);
+            _localPacketSize = (uint)random.Next(1000, 2000);
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(100, 200);
+            _sessionSemaphore = new SemaphoreLight(1);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                        {
+                            _sessionMock.Raise(
+                                s => s.ChannelOpenConfirmationReceived += null,
+                                new MessageEventArgs<ChannelOpenConfirmationMessage>(
+                                    new ChannelOpenConfirmationMessage(
+                                        _localChannelNumber,
+                                        _remoteWindowSize,
+                                        _remotePacketSize,
+                                        _remoteChannelNumber)));
+                        w.WaitOne();
+                    });
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelCloseReceived += null,
+                            new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+                        w.WaitOne();
+                    });
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+            _channel.Open();
+            _channel.Close();
+        }
+
+        protected virtual void Act()
+        {
+            _channel.Close();
+        }
+
+        internal ChannelSession Channel
+        {
+            get { return _channel; }
+        }
+
+        [TestMethod]
+        public void ChannelEofMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ChannelCloseMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldHaveFiredOnce()
+        {
+            Assert.AreEqual(1, _channelClosedRegister.Count);
+            Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 138 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen.cs

@@ -0,0 +1,138 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private ChannelSession _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private uint _remoteChannelNumber;
+        private SemaphoreLight _sessionSemaphore;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(2000, 3000);
+            _localPacketSize = (uint)random.Next(1000, 2000);
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(100, 200);
+            _sessionSemaphore = new SemaphoreLight(1);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                        {
+                            _sessionMock.Raise(
+                                s => s.ChannelOpenConfirmationReceived += null,
+                                new MessageEventArgs<ChannelOpenConfirmationMessage>(
+                                    new ChannelOpenConfirmationMessage(
+                                        _localChannelNumber,
+                                        _remoteWindowSize,
+                                        _remotePacketSize,
+                                        _remoteChannelNumber)));
+                        w.WaitOne();
+                    });
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelCloseReceived += null,
+                            new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+                        w.WaitOne();
+                    });
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+            _channel.Open();
+        }
+
+        private void Act()
+        {
+            _channel.Close();
+        }
+
+        [TestMethod]
+        public void ChannelEofMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ChannelCloseMessageShouldBeSentOnce()
+        {
+            _sessionMock.Verify(p => p.SendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldHaveFiredOnce()
+        {
+            Assert.AreEqual(1, _channelClosedRegister.Count);
+            Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 125 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived.cs

@@ -0,0 +1,125 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived
+    {
+        private Mock<ISession> _sessionMock;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteChannelNumber;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+        private ChannelSession _channel;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private MockSequence _sequence;
+        private SemaphoreLight _sessionSemaphore;
+        private int _initialSessionSemaphoreCount;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _localWindowSize = (uint) random.Next(0, int.MaxValue);
+            _localPacketSize = (uint) random.Next(0, int.MaxValue);
+            _remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint) random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint) random.Next(0, int.MaxValue);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+            _initialSessionSemaphoreCount = random.Next(10, 20);
+            _sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            _sequence = new MockSequence();
+            _sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(_sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(_sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelOpenConfirmationReceived += null,
+                            new MessageEventArgs<ChannelOpenConfirmationMessage>(
+                                new ChannelOpenConfirmationMessage(
+                                    _localChannelNumber,
+                                    _remoteWindowSize,
+                                    _remotePacketSize,
+                                    _remoteChannelNumber)));
+                        w.WaitOne();
+                    });
+            _sessionMock.Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(_sequence).Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+            _channel.Open();
+
+            _sessionMock.Raise(
+                p => p.ChannelCloseReceived += null,
+                new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+        }
+
+        private void Act()
+        {
+            _channel.Close();
+        }
+
+        [TestMethod]
+        public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
+        {
+            Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldHaveFiredOnce()
+        {
+            Assert.AreEqual(1, _channelClosedRegister.Count);
+            Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 13 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Disposed_Closed.cs

@@ -0,0 +1,13 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Disposed_Closed : ChannelSessionTest_Close_Closed
+    {
+        protected override void Act()
+        {
+            Channel.Dispose();
+        }
+    }
+}

+ 114 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_ExceptionWaitingOnOpenConfirmation.cs

@@ -0,0 +1,114 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Open_ExceptionWaitingOnOpenConfirmation
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private ChannelSession _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+        private SemaphoreLight _sessionSemaphore;
+        private int _initialSessionSemaphoreCount;
+        private Exception _waitOnConfirmationException;
+        private SystemException _actualException;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(2000, 3000);
+            _localPacketSize = (uint)random.Next(1000, 2000);
+            _initialSessionSemaphoreCount = random.Next(10, 20);
+            _sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+            _waitOnConfirmationException = new SystemException();
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Throws(_waitOnConfirmationException);
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+        }
+
+        private void Act()
+        {
+            try
+            {
+                _channel.Open();
+            }
+            catch (SystemException ex)
+            {
+                _actualException = ex;
+            }
+        }
+
+        [TestMethod]
+        public void OpenShouldHaveRethrownExceptionThrownByWaitOnHandle()
+        {
+            
+        }
+
+        [TestMethod]
+        public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
+        {
+            Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelClosedRegister.Count);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 139 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_OnOpenFailureReceived_NoRetriesAvailable.cs

@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Open_OnOpenFailureReceived_NoRetriesAvailable
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private ChannelSession _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+        private SemaphoreLight _sessionSemaphore;
+        private int _initialSessionSemaphoreCount;
+        private uint _failureReasonCode;
+        private string _failureDescription;
+        private string _failureLanguage;
+        private SshException _actualException;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
+            _localWindowSize = (uint) random.Next(2000, 3000);
+            _localPacketSize = (uint) random.Next(1000, 2000);
+            _initialSessionSemaphoreCount = random.Next(10, 20);
+            _sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+            _actualException = null;
+
+            _failureReasonCode = (uint)random.Next(0, int.MaxValue);
+            _failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
+            _failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                        {
+                            _sessionMock.Raise(
+                                s => s.ChannelOpenFailureReceived += null,
+                                new MessageEventArgs<ChannelOpenFailureMessage>(
+                                    new ChannelOpenFailureMessage(
+                                        _localChannelNumber,
+                                        _failureDescription,
+                                        _failureReasonCode,
+                                        _failureLanguage
+                                        )));
+                        w.WaitOne();
+                    });
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+        }
+
+        private void Act()
+        {
+            try
+            {
+                _channel.Open();
+            }
+            catch (SshException ex)
+            {
+                _actualException = ex;
+            }
+        }
+
+        [TestMethod]
+        public void OpenShouldHaveThrownSshException()
+        {
+            Assert.IsNotNull(_actualException);
+            Assert.AreEqual(typeof (SshException), _actualException.GetType());
+            Assert.IsNull(_actualException.InnerException);
+            Assert.AreEqual("Failed to open a channel after 1 attempts.", _actualException.Message);
+        }
+
+        [TestMethod]
+        public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
+        {
+            Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelClosedRegister.Count);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+    }
+}

+ 152 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelSessionTest_Open_OnOpenFailureReceived_RetriesAvalable.cs

@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Channels;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelSessionTest_Open_OnOpenFailureReceived_RetriesAvalable
+    {
+        private Mock<ISession> _sessionMock;
+        private Mock<IConnectionInfo> _connectionInfoMock;
+        private ChannelSession _channel;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteChannelNumber;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private List<ExceptionEventArgs> _channelExceptionRegister;
+        private SemaphoreLight _sessionSemaphore;
+        private int _initialSessionSemaphoreCount;
+        private uint _failureReasonCode;
+        private string _failureDescription;
+        private string _failureLanguage;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(2000, 3000);
+            _localPacketSize = (uint)random.Next(1000, 2000);
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
+            _initialSessionSemaphoreCount = random.Next(10, 20);
+            _sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+            _channelExceptionRegister = new List<ExceptionEventArgs>();
+
+            _failureReasonCode = (uint)random.Next(0, int.MaxValue);
+            _failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
+            _failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+            _connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                        {
+                            _sessionMock.Raise(
+                                s => s.ChannelOpenFailureReceived += null,
+                                new MessageEventArgs<ChannelOpenFailureMessage>(
+                                    new ChannelOpenFailureMessage(
+                                        _localChannelNumber,
+                                        _failureDescription,
+                                        _failureReasonCode,
+                                        _failureLanguage
+                                        )));
+                        w.WaitOne();
+                    });
+            _sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
+            _connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
+            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
+            _sessionMock.InSequence(sequence)
+                .Setup(
+                    p =>
+                        p.SendMessage(
+                            It.Is<ChannelOpenMessage>(
+                                m =>
+                                    m.LocalChannelNumber == _localChannelNumber &&
+                                    m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
+                                    m.Info is SessionChannelOpenInfo)));
+            _sessionMock.InSequence(sequence)
+                .Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
+                .Callback<WaitHandle>(
+                    w =>
+                    {
+                        _sessionMock.Raise(
+                            s => s.ChannelOpenConfirmationReceived += null,
+                            new MessageEventArgs<ChannelOpenConfirmationMessage>(
+                                new ChannelOpenConfirmationMessage(
+                                    _localChannelNumber,
+                                    _remoteWindowSize,
+                                    _remotePacketSize,
+                                    _remoteChannelNumber)));
+                        w.WaitOne();
+                    });
+
+            _channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
+            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
+        }
+
+        private void Act()
+        {
+            _channel.Open();
+        }
+
+        [TestMethod]
+        public void CurrentCountOfSessionSemaphoreShouldBeOneLessThanToInitialCount()
+        {
+            Assert.AreEqual(_initialSessionSemaphoreCount - 1, _sessionSemaphore.CurrentCount);
+        }
+
+        [TestMethod]
+        public void ExceptionShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelExceptionRegister.Count);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldNeverHaveFired()
+        {
+            Assert.AreEqual(0, _channelClosedRegister.Count);
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnTrue()
+        {
+            Assert.IsTrue(_channel.IsOpen);
+        }
+    }
+}

+ 12 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelStub.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using Renci.SshNet.Channels;
 using Renci.SshNet.Messages.Connection;
@@ -8,14 +7,22 @@ namespace Renci.SshNet.Tests.Classes.Channels
 {
     internal class ChannelStub : Channel
     {
-        public override ChannelTypes ChannelType
+        /// <summary>
+        /// Initializes a new <see cref="ChannelStub"/> instance.
+        /// </summary>
+        /// <param name="session">The session.</param>
+        /// <param name="localChannelNumber">The local channel number.</param>
+        /// <param name="localWindowSize">Size of the window.</param>
+        /// <param name="localPacketSize">Size of the packet.</param>
+        public ChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
+            : base(session, localChannelNumber, localWindowSize, localPacketSize)
         {
-            get { return ChannelTypes.X11; }
+            OnErrorOccurredInvocations = new List<Exception>();
         }
 
-        public ChannelStub()
+        public override ChannelTypes ChannelType
         {
-            OnErrorOccurredInvocations = new List<Exception>();
+            get { return ChannelTypes.X11; }
         }
 
         public IList<Exception> OnErrorOccurredInvocations { get; private set; }

+ 7 - 9
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsNotOpen.cs

@@ -28,25 +28,23 @@ namespace Renci.SshNet.Tests.Classes.Channels
         private void Arrange()
         {
             var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _localWindowSize = (uint)random.Next(0, int.MaxValue);
             _localPacketSize = (uint)random.Next(0, int.MaxValue);
-            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _channelClosedRegister = new List<ChannelEventArgs>();
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
-            {
-                lock (this)
                 {
-                    _channelClosedRegister.Add(args);
-                }
-            };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+                    lock (this)
+                    {
+                        _channelClosedRegister.Add(args);
+                    }
+                };
         }
 
         private void Act()

+ 134 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived.cs

@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived
+    {
+        private Mock<ISession> _sessionMock;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteChannelNumber;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private ChannelStub _channel;
+        private Stopwatch _closeTimer;
+        private List<ChannelEventArgs> _channelClosedRegister;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(0, int.MaxValue);
+            _localPacketSize = (uint)random.Next(0, int.MaxValue);
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
+            _closeTimer = new Stopwatch();
+            _channelClosedRegister = new List<ChannelEventArgs>();
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
+                .Callback<WaitHandle>(w =>
+                    {
+                        new Thread(() =>
+                            {
+                                Thread.Sleep(100);
+                                // raise ChannelCloseReceived event to set waithandle for receiving
+                                // SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
+                                // sending the SSH_MSG_CHANNEL_CLOSE message to the server
+                                _sessionMock.Raise(s => s.ChannelCloseReceived += null,
+                                    new MessageEventArgs<ChannelCloseMessage>(
+                                        new ChannelCloseMessage(_localChannelNumber)));
+                            }).Start();
+                        _closeTimer.Start();
+                        try
+                        {
+                            w.WaitOne();
+                        }
+                        finally
+                        {
+                            _closeTimer.Stop();
+                        }
+                    });
+
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) =>
+                {
+                    lock (this)
+                    {
+                        _channelClosedRegister.Add(args);
+                    }
+                };
+            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
+            _channel.SetIsOpen(true);
+        }
+
+        private void Act()
+        {
+            _channel.Close();
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+
+        [TestMethod]
+        public void SendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Once);
+        }
+
+        [TestMethod]
+        public void SendMessageOnSessionShouldBeInvokedOnceForChannelEofMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Once);
+        }
+
+        [TestMethod]
+        public void WaitOnHandleOnSessionShouldBeInvokedOnce()
+        {
+            _sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
+        }
+
+        [TestMethod]
+        public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
+        {
+            Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldHaveFiredOnce()
+        {
+            Assert.AreEqual(1, _channelClosedRegister.Count);
+            Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
+        }
+    }
+}

+ 23 - 12
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsOpen.cs → Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofReceived.cs

@@ -10,7 +10,7 @@ using Renci.SshNet.Messages.Connection;
 namespace Renci.SshNet.Tests.Classes.Channels
 {
     [TestClass]
-    public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen
+    public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofReceived
     {
         private Mock<ISession> _sessionMock;
         private uint _localChannelNumber;
@@ -44,10 +44,10 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-            _sessionMock.Setup(p => p.IsConnected).Returns(true);
-            _sessionMock.Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
-            _sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
+            var sequence = new MockSequence();
+            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
+            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
                 .Callback<WaitHandle>(w =>
                     {
                         new Thread(() =>
@@ -71,17 +71,20 @@ namespace Renci.SshNet.Tests.Classes.Channels
                         }
                     });
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
-            {
-                lock (this)
                 {
-                    _channelClosedRegister.Add(args);
-                }
-            };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+                    lock (this)
+                    {
+                        _channelClosedRegister.Add(args);
+                    }
+                };
             _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
             _channel.SetIsOpen(true);
+
+            _sessionMock.Raise(
+                s => s.ChannelEofReceived += null,
+                new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
         }
 
         private void Act()
@@ -103,6 +106,14 @@ namespace Renci.SshNet.Tests.Classes.Channels
                 Times.Once);
         }
 
+        [TestMethod]
+        public void SendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Never);
+        }
+
         [TestMethod]
         public void WaitOnHandleOnSessionShouldBeInvokedOnce()
         {

+ 7 - 9
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsNotConnectedAndChannelIsNotOpen.cs

@@ -28,25 +28,23 @@ namespace Renci.SshNet.Tests.Classes.Channels
         private void Arrange()
         {
             var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _localWindowSize = (uint) random.Next(0, int.MaxValue);
             _localPacketSize = (uint) random.Next(0, int.MaxValue);
-            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
             _channelClosedRegister = new List<ChannelEventArgs>();
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(false);
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
-            {
-                lock (this)
                 {
-                    _channelClosedRegister.Add(args);
-                }
-            };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+                    lock (this)
+                    {
+                        _channelClosedRegister.Add(args);
+                    }
+                };
         }
 
         private void Act()

+ 2 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_Close_SessionIsNotConnectedAndChannelIsOpen.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Moq;
-using Renci.SshNet.Channels;
 using Renci.SshNet.Common;
 using Renci.SshNet.Messages;
 
@@ -28,17 +27,16 @@ namespace Renci.SshNet.Tests.Classes.Channels
         private void Arrange()
         {
             var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _localWindowSize = (uint)random.Next(0, int.MaxValue);
             _localPacketSize = (uint)random.Next(0, int.MaxValue);
-            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _channelClosedRegister = new List<ChannelEventArgs>();
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(false);
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
                 {
                     lock (this)
@@ -46,7 +44,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
                         _channelClosedRegister.Add(args);
                     }
                 };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
             _channel.SetIsOpen(true);
         }
 

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_OnClose_Exception.cs

@@ -36,10 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnCloseException = _onCloseException;
         }

+ 10 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen.cs → Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofNotReceived.cs

@@ -9,7 +9,7 @@ using Renci.SshNet.Messages.Connection;
 namespace Renci.SshNet.Tests.Classes.Channels
 {
     [TestClass]
-    public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen
+    public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofNotReceived
     {
         private Mock<ISession> _sessionMock;
         private uint _localChannelNumber;
@@ -41,11 +41,10 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
             _sessionMock.Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
                 {
                     lock (this)
@@ -53,7 +52,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
                         _channelClosedRegister.Add(args);
                     }
                 };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
             _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
             _channel.SetIsOpen(true);
         }
@@ -78,6 +76,14 @@ namespace Renci.SshNet.Tests.Classes.Channels
                 Times.Once);
         }
 
+        [TestMethod]
+        public void SendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Never);
+        }
+
         [TestMethod]
         public void WaitOnHandleOnSessionShouldNeverBeInvoked()
         {

+ 103 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofReceived.cs

@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
+
+namespace Renci.SshNet.Tests.Classes.Channels
+{
+    [TestClass]
+    public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofReceived
+    {
+        private Mock<ISession> _sessionMock;
+        private uint _localChannelNumber;
+        private uint _localWindowSize;
+        private uint _localPacketSize;
+        private uint _remoteChannelNumber;
+        private uint _remoteWindowSize;
+        private uint _remotePacketSize;
+        private IList<ChannelEventArgs> _channelClosedRegister;
+        private ChannelStub _channel;
+
+        [TestInitialize]
+        public void Initialize()
+        {
+            Arrange();
+            Act();
+        }
+
+        private void Arrange()
+        {
+            var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _localWindowSize = (uint)random.Next(0, int.MaxValue);
+            _localPacketSize = (uint)random.Next(0, int.MaxValue);
+            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
+            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
+            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
+            _channelClosedRegister = new List<ChannelEventArgs>();
+
+            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
+
+            _sessionMock.Setup(p => p.IsConnected).Returns(true);
+            _sessionMock.Setup(p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
+
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
+            _channel.Closed += (sender, args) =>
+                {
+                    lock (this)
+                    {
+                        _channelClosedRegister.Add(args);
+                    }
+                };
+            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
+            _channel.SetIsOpen(true);
+
+            _sessionMock.Raise(p => p.ChannelEofReceived += null,
+                new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
+        }
+
+        private void Act()
+        {
+            _sessionMock.Raise(p => p.ChannelCloseReceived += null,
+                new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
+        }
+
+        [TestMethod]
+        public void IsOpenShouldReturnFalse()
+        {
+            Assert.IsFalse(_channel.IsOpen);
+        }
+
+        [TestMethod]
+        public void SendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Once);
+        }
+
+        [TestMethod]
+        public void SendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
+        {
+            _sessionMock.Verify(
+                p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
+                Times.Never);
+        }
+
+        [TestMethod]
+        public void WaitOnHandleOnSessionShouldNeverBeInvoked()
+        {
+            _sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Never);
+        }
+
+        [TestMethod]
+        public void ClosedEventShouldHaveFiredOnce()
+        {
+            Assert.AreEqual(1, _channelClosedRegister.Count);
+            Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
+        }
+    }
+}

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelDataReceived_OnData_Exception.cs

@@ -36,10 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnDataException = _onDataException;
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelEofReceived_OnEof_Exception.cs

@@ -42,10 +42,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
             _channel.SetIsOpen(true);

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelExtendedDataReceived_OnExtendedData_Exception.cs

@@ -36,10 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnExtendedDataException = _onExtendedDataException;
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelFailureReceived_OnFailure_Exception.cs

@@ -36,10 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnFailureException = _onFailureException;
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelRequestReceived_OnRequest_Exception.cs

@@ -40,10 +40,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _sessionMock.Setup(p => p.ConnectionInfo)
                 .Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnRequestException = _onRequestException;
         }

+ 2 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelSuccessReceived_OnSuccess_Exception.cs

@@ -28,18 +28,15 @@ namespace Renci.SshNet.Tests.Classes.Channels
         private void Arrange()
         {
             var random = new Random();
+            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _localWindowSize = (uint)random.Next(0, 1000);
             _localPacketSize = (uint)random.Next(1001, int.MaxValue);
-            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
             _onSuccessException = new SystemException();
             _channelExceptionRegister = new List<ExceptionEventArgs>();
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnSuccessException = _onSuccessException;
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionChannelWindowAdjustReceived_OnWindowAdjust_Exception.cs

@@ -44,10 +44,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnWindowAdjustException = _onWindowAdjustException;

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionDisconnected_OnDisconnected_Exception.cs

@@ -35,10 +35,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnDisconnectedException = _onDisconnectedException;
         }

+ 2 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionDisconnected_SessionIsConnectedAndChannelIsOpen.cs

@@ -38,10 +38,10 @@ namespace Renci.SshNet.Tests.Classes.Channels
             _channelClosedRegister = new List<ChannelEventArgs>();
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
+
             _sessionMock.Setup(p => p.IsConnected).Returns(true);
 
-            _channel = new ChannelStub();
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Closed += (sender, args) =>
                 {
                     lock (this)
@@ -49,7 +49,6 @@ namespace Renci.SshNet.Tests.Classes.Channels
                         _channelClosedRegister.Add(args);
                     }
                 };
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
             _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
             _channel.SetIsOpen(true);
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ChannelTest_OnSessionErrorOccurred_OnErrorOccurred_Exception.cs

@@ -37,10 +37,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnErrorOccurredException = _onErrorOccurredException;
         }

+ 12 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelStub.cs

@@ -7,14 +7,22 @@ namespace Renci.SshNet.Tests.Classes.Channels
 {
     internal class ClientChannelStub : ClientChannel
     {
-        public override ChannelTypes ChannelType
+        /// <summary>
+        /// Initializes a new <see cref="ClientChannelStub"/> instance.
+        /// </summary>
+        /// <param name="session">The session.</param>
+        /// <param name="localChannelNumber">The local channel number.</param>
+        /// <param name="localWindowSize">Size of the window.</param>
+        /// <param name="localPacketSize">Size of the packet.</param>
+        public ClientChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
+            : base(session, localChannelNumber, localWindowSize, localPacketSize)
         {
-            get { return ChannelTypes.X11; }
+            OnErrorOccurredInvocations = new List<Exception>();
         }
 
-        public ClientChannelStub()
+        public override ChannelTypes ChannelType
         {
-            OnErrorOccurredInvocations = new List<Exception>();
+            get { return ChannelTypes.X11; }
         }
 
         public IList<Exception> OnErrorOccurredInvocations { get; private set; }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception.cs

@@ -38,10 +38,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ClientChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnOpenConfirmationException = _onOpenConfirmationException;
         }

+ 1 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Channels/ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception.cs

@@ -36,10 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
 
             _sessionMock = new Mock<ISession>(MockBehavior.Strict);
 
-            _sessionMock.Setup(p => p.NextChannelNumber).Returns(_localChannelNumber);
-
-            _channel = new ClientChannelStub();
-            _channel.Initialize(_sessionMock.Object, _localWindowSize, _localPacketSize);
+            _channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
             _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
             _channel.OnOpenFailureException = _onOpenFailureException;
         }

+ 12 - 25
Renci.SshClient/Renci.SshNet.Tests/Classes/CommandAsyncResultTest.cs

@@ -1,45 +1,32 @@
-using Renci.SshNet;
+using System;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes
 {
-    /// <summary>
-    ///This is a test class for CommandAsyncResultTest and is intended
-    ///to contain all CommandAsyncResultTest Unit Tests
-    ///</summary>
     [TestClass()]
     public class CommandAsyncResultTest : TestBase
     {
-        /// <summary>
-        ///A test for BytesSent
-        ///</summary>
         [TestMethod()]
         public void BytesSentTest()
         {
-            CommandAsyncResult target = new CommandAsyncResult(); // TODO: Initialize to an appropriate value
-            int expected = 0; // TODO: Initialize to an appropriate value
-            int actual;
+            var target = new CommandAsyncResult();
+            int expected = new Random().Next();
+
             target.BytesSent = expected;
-            actual = target.BytesSent;
-            Assert.AreEqual(expected, actual);
-            Assert.Inconclusive("Verify the correctness of this test method.");
+
+            Assert.AreEqual(expected, target.BytesSent);
         }
 
-        /// <summary>
-        ///A test for BytesReceived
-        ///</summary>
         [TestMethod()]
         public void BytesReceivedTest()
         {
-            CommandAsyncResult target = new CommandAsyncResult(); // TODO: Initialize to an appropriate value
-            int expected = 0; // TODO: Initialize to an appropriate value
-            int actual;
+            var target = new CommandAsyncResult();
+            var expected = new Random().Next();
+
             target.BytesReceived = expected;
-            actual = target.BytesReceived;
-            Assert.AreEqual(expected, actual);
-            Assert.Inconclusive("Verify the correctness of this test method.");
+
+            Assert.AreEqual(expected, target.BytesReceived);
         }
     }
 }

+ 2 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/AsyncResultTest.cs

@@ -6,13 +6,12 @@ using Renci.SshNet.Tests.Common;
 
 namespace Renci.SshNet.Tests.Classes.Common
 {
-    
-    
     /// <summary>
     ///This is a test class for AsyncResultTest and is intended
     ///to contain all AsyncResultTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholder for actual test
     public class AsyncResultTest : TestBase
     {
         /// <summary>

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/BigIntegerTest.cs

@@ -11,6 +11,7 @@ namespace Renci.SshNet.Tests.Classes.Common
     ///to contain all BigIntegerTest Unit Tests
     ///</summary>
     [TestClass()]
+    [Ignore] // placeholder for actual test
     public class BigIntegerTest : TestBase
     {
         /// <summary>

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/DerDataTest.cs

@@ -10,6 +10,7 @@ namespace Renci.SshNet.Tests.Classes.Common
     ///to contain all DerDataTest Unit Tests
     ///</summary>
     [TestClass()]
+    [Ignore] // placeholder for actual test
     public class DerDataTest : TestBase
     {
         /// <summary>

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/HostKeyEventArgsTest.cs

@@ -11,6 +11,7 @@ namespace Renci.SshNet.Tests.Classes.Common
     ///to contain all HostKeyEventArgsTest Unit Tests
     ///</summary>
     [TestClass()]
+    [Ignore] // placeholder for actual test
     public class HostKeyEventArgsTest : TestBase
     {
         /// <summary>

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/ObjectIdentifierTest.cs

@@ -10,6 +10,7 @@ namespace Renci.SshNet.Tests.Classes.Common
     ///to contain all ObjectIdentifierTest Unit Tests
     ///</summary>
     [TestClass()]
+    [Ignore] // placeholder for actual test
     public class ObjectIdentifierTest : TestBase
     {
         /// <summary>

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshConnectionExceptionTest.cs

@@ -76,6 +76,7 @@ namespace Renci.SshNet.Tests.Classes.Common
         ///A test for GetObjectData
         ///</summary>
         [TestMethod()]
+        [Ignore] // placeholder for actual test
         public void GetObjectDataTest()
         {
             SshConnectionException target = new SshConnectionException(); // TODO: Initialize to an appropriate value

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshDataTest.cs

@@ -10,6 +10,7 @@ namespace Renci.SshNet.Tests.Classes.Common
     ///to contain all SshDataTest Unit Tests
     ///</summary>
     [TestClass()]
+    [Ignore] // placeholder for actual test
     public class SshDataTest : TestBase
     {
         internal virtual SshData CreateSshData()

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Common/SshExceptionTest.cs

@@ -50,6 +50,7 @@ namespace Renci.SshNet.Tests.Classes.Common
         ///A test for GetObjectData
         ///</summary>
         [TestMethod()]
+        [Ignore] // placeholder for actual test
         public void GetObjectDataTest()
         {
             SshException target = new SshException(); // TODO: Initialize to an appropriate value

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Compression/CompressorTest.cs

@@ -10,7 +10,8 @@ namespace Renci.SshNet.Tests.Classes.Compression
     ///This is a test class for CompressorTest and is intended
     ///to contain all CompressorTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class CompressorTest : TestBase
     {
         internal virtual Compressor CreateCompressor()

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Compression/ZlibOpenSshTest.cs

@@ -10,7 +10,8 @@ namespace Renci.SshNet.Tests.Classes.Compression
     ///This is a test class for ZlibOpenSshTest and is intended
     ///to contain all ZlibOpenSshTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class ZlibOpenSshTest : TestBase
     {
         /// <summary>

+ 19 - 20
Renci.SshClient/Renci.SshNet.Tests/Classes/ExpectActionTest.cs

@@ -1,38 +1,37 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Globalization;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Renci.SshNet.Tests.Common;
 using System;
 using System.Text.RegularExpressions;
 
 namespace Renci.SshNet.Tests.Classes
 {
-    /// <summary>
-    /// Specifies behavior for expected expression
-    /// </summary>
     [TestClass]
     public class ExpectActionTest : TestBase
     {
-        /// <summary>
-        ///A test for ExpectAction Constructor
-        ///</summary>
         [TestMethod()]
-        public void ExpectActionConstructorTest()
+        public void Constructor_StringAndAction()
         {
-            string expect = string.Empty; // TODO: Initialize to an appropriate value
-            Action<string> action = null; // TODO: Initialize to an appropriate value
-            ExpectAction target = new ExpectAction(expect, action);
-            Assert.Inconclusive("TODO: Implement code to verify target");
+            var expect = new Random().Next().ToString(CultureInfo.InvariantCulture);
+            Action<string> action = Console.WriteLine;
+
+            var target = new ExpectAction(expect, action);
+
+            Assert.IsNotNull(target.Expect);
+            Assert.AreEqual(expect, target.Expect.ToString());
+            Assert.AreSame(action, target.Action);
         }
 
-        /// <summary>
-        ///A test for ExpectAction Constructor
-        ///</summary>
         [TestMethod()]
-        public void ExpectActionConstructorTest1()
+        public void Constructor_RegexAndAction()
         {
-            Regex expect = null; // TODO: Initialize to an appropriate value
-            Action<string> action = null; // TODO: Initialize to an appropriate value
-            ExpectAction target = new ExpectAction(expect, action);
-            Assert.Inconclusive("TODO: Implement code to verify target");
+            var expect = new Regex("^.*");
+            Action<string> action = Console.WriteLine;
+
+            var target = new ExpectAction(expect, action);
+
+            Assert.AreSame(expect, target.Expect);
+            Assert.AreSame(action, target.Action);
         }
     }
 }

+ 19 - 20
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest.cs

@@ -1,35 +1,34 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Globalization;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Renci.SshNet.Tests.Common;
 
 namespace Renci.SshNet.Tests.Classes
 {
-    /// <summary>
-    /// Provides functionality for dynamic port forwarding
-    /// </summary>
     [TestClass]
-    public partial class ForwardedPortDynamicTest : TestBase
+    public class ForwardedPortDynamicTest : TestBase
     {
-        /// <summary>
-        ///A test for ForwardedPortDynamic Constructor
-        ///</summary>
         [TestMethod()]
-        public void ForwardedPortDynamicConstructorTest()
+        public void Constructor_HostAndPort()
         {
-            string host = string.Empty; // TODO: Initialize to an appropriate value
-            uint port = 0; // TODO: Initialize to an appropriate value
-            ForwardedPortDynamic target = new ForwardedPortDynamic(host, port);
-            Assert.Inconclusive("TODO: Implement code to verify target");
+            var host = new Random().Next().ToString(CultureInfo.InvariantCulture);
+            var port = (uint) new Random().Next(0, int.MaxValue);
+
+            var target = new ForwardedPortDynamic(host, port);
+
+            Assert.AreSame(host, target.BoundHost);
+            Assert.AreEqual(port, target.BoundPort);
         }
 
-        /// <summary>
-        ///A test for ForwardedPortDynamic Constructor
-        ///</summary>
         [TestMethod()]
-        public void ForwardedPortDynamicConstructorTest1()
+        public void Constructor_Port()
         {
-            uint port = 0; // TODO: Initialize to an appropriate value
-            ForwardedPortDynamic target = new ForwardedPortDynamic(port);
-            Assert.Inconclusive("TODO: Implement code to verify target");
+            var port = (uint)new Random().Next(0, int.MaxValue);
+
+            var target = new ForwardedPortDynamic(port);
+
+            Assert.AreSame(string.Empty, target.BoundHost);
+            Assert.AreEqual(port, target.BoundPort);
         }
     }
 }

+ 9 - 12
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.NET40.cs

@@ -1,21 +1,17 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System;
+using System;
 using System.Diagnostics;
 using System.IO;
 using System.Net;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Tests.Properties;
 
-namespace Renci.SshNet.Tests.SshClientTests
+namespace Renci.SshNet.Tests.Classes
 {
-    /// <summary>
-    /// Summary description for UnitTest1
-    /// </summary>
-    [TestClass]
-    public partial class ForwardedPortLocalTest : TestBase
+    public partial class ForwardedPortLocalTest
     {
         [TestMethod]
+        [TestCategory("integration")]
         [ExpectedException(typeof(SshConnectionException))]
         public void Test_PortForwarding_Local_Without_Connecting()
         {
@@ -52,6 +48,7 @@ namespace Renci.SshNet.Tests.SshClientTests
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_PortForwarding_Local()
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
@@ -90,7 +87,7 @@ namespace Renci.SshNet.Tests.SshClientTests
         private static byte[] ReadStream(Stream stream)
         {
             byte[] buffer = new byte[1024];
-            using (MemoryStream ms = new MemoryStream())
+            using (var ms = new MemoryStream())
             {
                 while (true)
                 {

+ 3 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest.cs

@@ -19,6 +19,7 @@ namespace Renci.SshNet.Tests.Classes
         [WorkItem(713)]
         [Owner("Kenneth_aa")]
         [TestCategory("PortForwarding")]
+        [TestCategory("integration")]
         [Description("Test if calling Stop on ForwardedPortLocal instance causes wait.")]
         public void Test_PortForwarding_Local_Stop_Hangs_On_Wait()
         {
@@ -163,7 +164,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ForwardedPortRemote Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [TestCategory("integration")]
         public void Test_ForwardedPortRemote()
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))

+ 0 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortStopped.cs

@@ -4,7 +4,6 @@ using System.Net;
 using System.Net.Sockets;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Moq;
-using Renci.SshNet.Channels;
 using Renci.SshNet.Common;
 
 namespace Renci.SshNet.Tests.Classes

+ 7 - 11
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortRemote.NET40.cs

@@ -1,20 +1,16 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Common;
-using Renci.SshNet.Tests.Common;
-using Renci.SshNet.Tests.Properties;
-using System;
+using System;
 using System.Diagnostics;
 using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Tests.Properties;
 
-namespace Renci.SshNet.Tests.SshClientTests
+namespace Renci.SshNet.Tests.Classes
 {
-    /// <summary>
-    /// Summary description for UnitTest1
-    /// </summary>
-    [TestClass]
-    public partial class ForwardedPortRemoteTest : TestBase
+    public partial class ForwardedPortRemoteTest
     {
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_PortForwarding_Remote()
         {
             //  ******************************************************************

+ 25 - 16
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest.cs

@@ -17,6 +17,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         [Description("Test passing null to AddForwardedPort hosts (remote).")]
         [ExpectedException(typeof(ArgumentNullException))]
+        [TestCategory("integration")]
         public void Test_AddForwardedPort_Remote_Hosts_Are_Null()
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
@@ -31,6 +32,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         [Description("Test passing invalid port numbers to AddForwardedPort.")]
         [ExpectedException(typeof(ArgumentOutOfRangeException))]
+        [TestCategory("integration")]
         public void Test_AddForwardedPort_Invalid_PortNumber()
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
@@ -45,7 +47,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ForwardedPortRemote Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [TestCategory("integration")]
         public void Test_ForwardedPortRemote()
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
@@ -72,7 +75,7 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Stop
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
         public void StopTest()
         {
             uint boundPort = 0; // TODO: Initialize to an appropriate value
@@ -83,24 +86,30 @@ namespace Renci.SshNet.Tests.Classes
             Assert.Inconclusive("A method that does not return a value cannot be verified.");
         }
 
-        /// <summary>
-        ///A test for Start
-        ///</summary>
-        [TestMethod()]
-        public void StartTest()
+        [TestMethod]
+        public void Start_NotAddedToClient()
         {
-            uint boundPort = 0; // TODO: Initialize to an appropriate value
-            string host = string.Empty; // TODO: Initialize to an appropriate value
-            uint port = 0; // TODO: Initialize to an appropriate value
-            ForwardedPortRemote target = new ForwardedPortRemote(boundPort, host, port); // TODO: Initialize to an appropriate value
-            target.Start();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
+            const int boundPort = 80;
+            string host = string.Empty;
+            const uint port = 22;
+            var target = new ForwardedPortRemote(boundPort, host, port);
+
+            try
+            {
+                target.Start();
+                Assert.Fail();
+            }
+            catch (InvalidOperationException ex)
+            {
+                Assert.IsNull(ex.InnerException);
+                Assert.AreEqual("Forwarded port is not added to a client.", ex.Message);
+            }
         }
 
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
         public void DisposeTest()
         {
             uint boundPort = 0; // TODO: Initialize to an appropriate value
@@ -114,7 +123,7 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ForwardedPortRemote Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
         public void ForwardedPortRemoteConstructorTest()
         {
             string boundHost = string.Empty; // TODO: Initialize to an appropriate value
@@ -128,7 +137,7 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ForwardedPortRemote Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
         public void ForwardedPortRemoteConstructorTest1()
         {
             uint boundPort = 0; // TODO: Initialize to an appropriate value

+ 0 - 44
Renci.SshClient/Renci.SshNet.Tests/Classes/ForwardedPortTest.cs

@@ -1,44 +0,0 @@
-using Renci.SshNet;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests
-{
-    /// <summary>
-    ///This is a test class for ForwardedPortTest and is intended
-    ///to contain all ForwardedPortTest Unit Tests
-    ///</summary>
-    [TestClass()]
-    public class ForwardedPortTest : TestBase
-    {
-        internal virtual ForwardedPort CreateForwardedPort()
-        {
-            // TODO: Instantiate an appropriate concrete class.
-            ForwardedPort target = null;
-            return target;
-        }
-
-        /// <summary>
-        ///A test for Stop
-        ///</summary>
-        [TestMethod()]
-        public void StopTest()
-        {
-            ForwardedPort target = CreateForwardedPort(); // TODO: Initialize to an appropriate value
-            target.Stop();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-
-        /// <summary>
-        ///A test for Start
-        ///</summary>
-        [TestMethod()]
-        public void StartTest()
-        {
-            ForwardedPort target = CreateForwardedPort(); // TODO: Initialize to an appropriate value
-            target.Start();
-            Assert.Inconclusive("A method that does not return a value cannot be verified.");
-        }
-    }
-}

+ 8 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs

@@ -33,7 +33,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Name
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NameTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -46,7 +47,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -58,7 +60,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Authenticate
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AuthenticateTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -74,7 +77,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveAuthenticationMethod Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveAuthenticationMethodConstructorTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value

+ 19 - 9
Renci.SshClient/Renci.SshNet.Tests/Classes/KeyboardInteractiveConnectionInfoTest.cs

@@ -14,6 +14,7 @@ namespace Renci.SshNet.Tests.Classes
     {
         [TestMethod]
         [TestCategory("KeyboardInteractiveConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_KeyboardInteractiveConnectionInfo()
         {
             var host = Resources.HOST;
@@ -48,7 +49,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -61,7 +63,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -79,7 +82,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest1()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -96,7 +100,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest2()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -112,7 +117,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest3()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -127,7 +133,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest4()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -144,7 +151,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest5()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -160,7 +168,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest6()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -173,7 +182,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for KeyboardInteractiveConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void KeyboardInteractiveConnectionInfoConstructorTest7()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/MessageEventArgsTest.cs

@@ -20,7 +20,8 @@ namespace Renci.SshNet.Tests.Classes
             Assert.Inconclusive("TODO: Implement code to verify target");
         }
 
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void MessageEventArgsConstructorTest()
         {
             MessageEventArgsConstructorTestHelper<GenericParameterHelper>();

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelMessageTest.cs

@@ -9,7 +9,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
     ///This is a test class for ChannelMessageTest and is intended
     ///to contain all ChannelMessageTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class ChannelMessageTest : TestBase
     {
         internal virtual ChannelMessage CreateChannelMessage()

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelOpen/ChannelOpenMessageTest.cs

@@ -9,7 +9,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
     ///This is a test class for ChannelOpenMessageTest and is intended
     ///to contain all ChannelOpenMessageTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class ChannelOpenMessageTest : TestBase
     {
         /// <summary>

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelOpenInfoTest.cs

@@ -9,7 +9,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
     ///This is a test class for ChannelOpenInfoTest and is intended
     ///to contain all ChannelOpenInfoTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class ChannelOpenInfoTest : TestBase
     {
         internal virtual ChannelOpenInfo CreateChannelOpenInfo()

+ 1 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelRequest/ChannelRequestMessageTest.cs

@@ -8,6 +8,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
     /// Represents SSH_MSG_CHANNEL_REQUEST message.
     /// </summary>
     [TestClass]
+    [Ignore] // placeholders only
     public class ChannelRequestMessageTest : TestBase
     {
         /// <summary>

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/Connection/RequestInfoTest.cs

@@ -9,7 +9,8 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
     ///This is a test class for RequestInfoTest and is intended
     ///to contain all RequestInfoTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class RequestInfoTest : TestBase
     {
         internal virtual RequestInfo CreateRequestInfo()

+ 2 - 1
Renci.SshClient/Renci.SshNet.Tests/Classes/Messages/MessageTest.cs

@@ -9,7 +9,8 @@ namespace Renci.SshNet.Tests.Classes.Messages
     ///This is a test class for MessageTest and is intended
     ///to contain all MessageTest Unit Tests
     ///</summary>
-    [TestClass()]
+    [TestClass]
+    [Ignore] // placeholders only
     public class MessageTest : TestBase
     {
         internal virtual Message CreateMessage()

+ 24 - 12
Renci.SshClient/Renci.SshNet.Tests/Classes/NetConfClientTest.cs

@@ -15,7 +15,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NetConfClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NetConfClientConstructorTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -28,7 +29,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NetConfClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NetConfClientConstructorTest1()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -42,7 +44,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NetConfClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NetConfClientConstructorTest2()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -55,7 +58,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NetConfClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NetConfClientConstructorTest3()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -69,7 +73,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NetConfClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NetConfClientConstructorTest4()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -80,7 +85,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for SendReceiveRpc
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SendReceiveRpcTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -96,7 +102,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for SendReceiveRpc
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SendReceiveRpcTest1()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -112,7 +119,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for SendCloseRpc
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SendCloseRpcTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -127,7 +135,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ServerCapabilities
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ServerCapabilitiesTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -140,7 +149,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for OperationTimeout
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void OperationTimeoutTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -156,7 +166,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ClientCapabilities
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ClientCapabilitiesTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -169,7 +180,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for AutomaticMessageIdHandling
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AutomaticMessageIdHandlingTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value

+ 0 - 10
Renci.SshClient/Renci.SshNet.Tests/Classes/Netconf/NetConfSessionTest.cs

@@ -1,10 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Renci.SshNet.Tests.Common;
-
-namespace Renci.SshNet.Tests.Classes.NetConf
-{
-    [TestClass]
-    public class NetConfSessionTest : TestBase
-    {
-    }
-}

+ 23 - 14
Renci.SshClient/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs

@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Globalization;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Renci.SshNet.Tests.Common;
 using System;
 
@@ -30,23 +31,29 @@ namespace Renci.SshNet.Tests.Classes
             new NoneAuthenticationMethod(string.Empty);
         }
 
-        /// <summary>
-        ///A test for Name
-        ///</summary>
-        [TestMethod()]
-        public void NameTest()
+        [TestMethod]
+        public void Name()
         {
-            string username = string.Empty; // TODO: Initialize to an appropriate value
-            NoneAuthenticationMethod target = new NoneAuthenticationMethod(username); // TODO: Initialize to an appropriate value
-            string actual;
-            actual = target.Name;
-            Assert.Inconclusive("Verify the correctness of this test method.");
+            var username = new Random().Next().ToString(CultureInfo.InvariantCulture);
+            var target = new NoneAuthenticationMethod(username);
+
+            Assert.AreEqual("none", target.Name);
+        }
+
+        [TestMethod]
+        public void Username()
+        {
+            var username = new Random().Next().ToString(CultureInfo.InvariantCulture);
+            var target = new NoneAuthenticationMethod(username);
+
+            Assert.AreSame(username, target.Username);
         }
 
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -58,7 +65,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Authenticate
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AuthenticateTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -74,7 +82,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for NoneAuthenticationMethod Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NoneAuthenticationMethodConstructorTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value

+ 11 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs

@@ -62,6 +62,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         [WorkItem(1140)]
         [TestCategory("BaseClient")]
+        [TestCategory("integration")]
         [Description("Test whether IsConnected is false after disconnect.")]
         [Owner("Kenneth_aa")]
         public void Test_BaseClient_IsConnected_True_After_Disconnect()
@@ -87,7 +88,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Name
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NameTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -101,7 +103,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -114,7 +117,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Authenticate
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AuthenticateTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -131,7 +135,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordAuthenticationMethod Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordAuthenticationMethodConstructorTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -143,7 +148,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordAuthenticationMethod Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordAuthenticationMethodConstructorTest1()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value

+ 49 - 27
Renci.SshClient/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs

@@ -15,6 +15,7 @@ namespace Renci.SshNet.Tests.Classes
     {
         [TestMethod]
         [TestCategory("PasswordConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_PasswordConnectionInfo()
         {
             var host = Resources.HOST;
@@ -37,6 +38,7 @@ namespace Renci.SshNet.Tests.Classes
 
         [TestMethod]
         [TestCategory("PasswordConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_PasswordConnectionInfo_PasswordExpired()
         {
             var host = Resources.HOST;
@@ -63,6 +65,7 @@ namespace Renci.SshNet.Tests.Classes
         }
         [TestMethod]
         [TestCategory("PasswordConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_PasswordConnectionInfo_AuthenticationBanner()
         {
             var host = Resources.HOST;
@@ -90,10 +93,19 @@ namespace Renci.SshNet.Tests.Classes
 
         [WorkItem(703), TestMethod]
         [TestCategory("PasswordConnectionInfo")]
-        [ExpectedException(typeof(ArgumentException))]
         public void Test_ConnectionInfo_Host_Is_Null()
         {
-            var connectionInfo = new PasswordConnectionInfo(null, Resources.USERNAME, Resources.PASSWORD);
+            try
+            {
+                new PasswordConnectionInfo(null, Resources.USERNAME, Resources.PASSWORD);
+                Assert.Fail();
+            }
+            catch (ArgumentNullException ex)
+            {
+                Assert.IsNull(ex.InnerException);
+                Assert.AreEqual("host", ex.ParamName);
+            }
+
         }
 
         [WorkItem(703), TestMethod]
@@ -112,15 +124,6 @@ namespace Renci.SshNet.Tests.Classes
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null);
         }
 
-        [TestMethod]
-        [TestCategory("PasswordConnectionInfo")]
-        [Description("Test passing whitespace to host parameter.")]
-        [ExpectedException(typeof(ArgumentException))]
-        public void Test_ConnectionInfo_Host_Is_Whitespace()
-        {
-            var connectionInfo = new PasswordConnectionInfo(" ", Resources.USERNAME, Resources.PASSWORD);
-        }
-
         [TestMethod]
         [TestCategory("PasswordConnectionInfo")]
         [Description("Test passing whitespace to username parameter.")]
@@ -150,6 +153,7 @@ namespace Renci.SshNet.Tests.Classes
         [Owner("Kenneth_aa")]
         [Description("Test connect to remote server via a SOCKS4 proxy server.")]
         [TestCategory("Proxy")]
+        [TestCategory("integration")]
         public void Test_Ssh_Connect_Via_Socks4()
         {
             var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks4, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
@@ -167,6 +171,7 @@ namespace Renci.SshNet.Tests.Classes
         [Owner("Kenneth_aa")]
         [Description("Test connect to remote server via a TCP SOCKS5 proxy server.")]
         [TestCategory("Proxy")]
+        [TestCategory("integration")]
         public void Test_Ssh_Connect_Via_TcpSocks5()
         {
             var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks5, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
@@ -183,6 +188,7 @@ namespace Renci.SshNet.Tests.Classes
         [Owner("Kenneth_aa")]
         [Description("Test connect to remote server via a HTTP proxy server.")]
         [TestCategory("Proxy")]
+        [TestCategory("integration")]
         public void Test_Ssh_Connect_Via_HttpProxy()
         {
             var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
@@ -199,7 +205,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -213,7 +220,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -232,7 +240,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest1()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -250,7 +259,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest2()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -267,7 +277,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest3()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -283,7 +294,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest4()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -301,7 +313,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest5()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -318,7 +331,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest6()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -332,7 +346,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest7()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -345,7 +360,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest8()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -363,7 +379,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest9()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -380,7 +397,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest10()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -396,7 +414,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest11()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -414,7 +433,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest12()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -431,7 +451,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest13()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -445,7 +466,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PasswordConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PasswordConnectionInfoConstructorTest14()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value

+ 8 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs

@@ -46,7 +46,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Name
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NameTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -60,7 +61,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -73,7 +75,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Authenticate
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AuthenticateTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value
@@ -90,7 +93,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyAuthenticationMethod Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyAuthenticationMethodConstructorTest()
         {
             string username = string.Empty; // TODO: Initialize to an appropriate value

+ 20 - 9
Renci.SshClient/Renci.SshNet.Tests/Classes/PrivateKeyConnectionInfoTest.cs

@@ -14,6 +14,7 @@ namespace Renci.SshNet.Tests.Classes
     {
         [TestMethod]
         [TestCategory("PrivateKeyConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_PrivateKeyConnectionInfo()
         {
             var host = Resources.HOST;
@@ -35,6 +36,7 @@ namespace Renci.SshNet.Tests.Classes
 
         [TestMethod]
         [TestCategory("PrivateKeyConnectionInfo")]
+        [TestCategory("integration")]
         public void Test_PrivateKeyConnectionInfo_MultiplePrivateKey()
         {
             var host = Resources.HOST;
@@ -60,7 +62,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -74,7 +77,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -93,7 +97,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest1()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -111,7 +116,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest2()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -128,7 +134,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest3()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -144,7 +151,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest4()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -162,7 +170,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest5()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -179,7 +188,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest6()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -193,7 +203,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for PrivateKeyConnectionInfo Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PrivateKeyConnectionInfoConstructorTest7()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value

+ 50 - 49
Renci.SshClient/Renci.SshNet.Tests/Classes/ScpClientTest.cs

@@ -15,22 +15,12 @@ namespace Renci.SshNet.Tests.Classes
     [TestClass]
     public partial class ScpClientTest : TestBase
     {
-        protected override void OnInit()
-        {
-            base.OnInit();
-
-            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
-            {
-                client.Connect();
-                client.RunCommand("rm -rf *");
-                client.Disconnect();
-            }
-        }
-
         [TestMethod]
         [TestCategory("Scp")]
         public void Test_Scp_File_Upload_Download()
         {
+            RemoveAllFiles();
+
             using (var scp = new ScpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
                 scp.Connect();
@@ -61,6 +51,8 @@ namespace Renci.SshNet.Tests.Classes
         [TestCategory("Scp")]
         public void Test_Scp_Stream_Upload_Download()
         {
+            RemoveAllFiles();
+
             using (var scp = new ScpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
                 scp.Connect();
@@ -98,6 +90,8 @@ namespace Renci.SshNet.Tests.Classes
         [TestCategory("Scp")]
         public void Test_Scp_10MB_File_Upload_Download()
         {
+            RemoveAllFiles();
+
             using (var scp = new ScpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
                 scp.Connect();
@@ -128,6 +122,8 @@ namespace Renci.SshNet.Tests.Classes
         [TestCategory("Scp")]
         public void Test_Scp_10MB_Stream_Upload_Download()
         {
+            RemoveAllFiles();
+
             using (var scp = new ScpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
                 scp.Connect();
@@ -165,6 +161,8 @@ namespace Renci.SshNet.Tests.Classes
         [TestCategory("Scp")]
         public void Test_Scp_Directory_Upload_Download()
         {
+            RemoveAllFiles();
+
             using (var scp = new ScpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
                 scp.Connect();
@@ -207,7 +205,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for OperationTimeout
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void OperationTimeoutTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -223,7 +222,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for BufferSize
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void BufferSizeTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -239,7 +239,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Upload
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void UploadTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -253,7 +254,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Upload
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void UploadTest1()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -267,7 +269,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Upload
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void UploadTest2()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -281,7 +284,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Download
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DownloadTest()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -295,7 +299,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Download
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DownloadTest1()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -309,7 +314,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for Download
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DownloadTest2()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -323,7 +329,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ScpClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ScpClientConstructorTest()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -336,7 +343,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ScpClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ScpClientConstructorTest1()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -350,7 +358,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ScpClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ScpClientConstructorTest2()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -363,7 +372,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ScpClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ScpClientConstructorTest3()
         {
             string host = string.Empty; // TODO: Initialize to an appropriate value
@@ -377,7 +387,8 @@ namespace Renci.SshNet.Tests.Classes
         /// <summary>
         ///A test for ScpClient Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void ScpClientConstructorTest4()
         {
             ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
@@ -385,41 +396,31 @@ namespace Renci.SshNet.Tests.Classes
             Assert.Inconclusive("TODO: Implement code to verify target");
         }
 
-
-        /// <summary>
-        /// Creates the test file.
-        /// </summary>
-        /// <param name="fileName">Name of the file.</param>
-        /// <param name="size">Size in megabytes.</param>
-        private void CreateTestFile(string fileName, int size)
-        {
-            using (var testFile = File.Create(fileName))
-            {
-                var random = new Random();
-                for (int i = 0; i < 1024 * size; i++)
-                {
-                    var buffer = new byte[1024];
-                    random.NextBytes(buffer);
-                    testFile.Write(buffer, 0, buffer.Length);
-                }
-            }
-        }
-
         protected static string CalculateMD5(string fileName)
         {
-            using (FileStream file = new FileStream(fileName, FileMode.Open))
+            using (var file = new FileStream(fileName, FileMode.Open))
             {
                 var md5 = new MD5CryptoServiceProvider();
                 byte[] retVal = md5.ComputeHash(file);
                 file.Close();
 
-                StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < retVal.Length; i++)
+                var sb = new StringBuilder();
+                for (var i = 0; i < retVal.Length; i++)
                 {
-                    sb.Append(retVal[i].ToString("x2"));
+                    sb.Append(i.ToString("x2"));
                 }
                 return sb.ToString();
             }
         }
+
+        private static void RemoveAllFiles()
+        {
+            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
+            {
+                client.Connect();
+                client.RunCommand("rm -rf *");
+                client.Disconnect();
+            }
+        }
     }
 }

+ 5 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/AlgorithmTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security
 {
     /// <summary>
     ///This is a test class for AlgorithmTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Name
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void NameTest()
         {
             Algorithm target = CreateAlgorithm(); // TODO: Initialize to an appropriate value

+ 10 - 8
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security
 {
     /// <summary>
     ///This is a test class for CertificateHostAlgorithmTest and is intended
@@ -15,7 +14,7 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for CertificateHostAlgorithm Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
         public void CertificateHostAlgorithmConstructorTest()
         {
             string name = string.Empty; // TODO: Initialize to an appropriate value
@@ -26,7 +25,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Sign
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SignTest()
         {
             string name = string.Empty; // TODO: Initialize to an appropriate value
@@ -42,7 +42,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for VerifySignature
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void VerifySignatureTest()
         {
             string name = string.Empty; // TODO: Initialize to an appropriate value
@@ -59,7 +60,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Data
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DataTest()
         {
             string name = string.Empty; // TODO: Initialize to an appropriate value

+ 7 - 6
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherDigitalSignatureTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
 {
     /// <summary>
     ///This is a test class for CipherDigitalSignatureTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Sign
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SignTest()
         {
             CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value
@@ -37,7 +37,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Verify
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void VerifyTest()
         {
             CipherDigitalSignature target = CreateCipherDigitalSignature(); // TODO: Initialize to an appropriate value

+ 7 - 6
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/CipherTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
 {
     /// <summary>
     ///This is a test class for CipherTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Decrypt
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptTest()
         {
             Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value
@@ -37,7 +37,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Encrypt
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptTest()
         {
             Cipher target = CreateCipher(); // TODO: Initialize to an appropriate value

+ 13 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs

@@ -45,6 +45,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_AEes128CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -61,6 +62,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Aes192CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -77,6 +79,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Aes256CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -93,6 +96,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Aes128CTR_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -109,6 +113,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Aes192CTR_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -125,6 +130,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Aes256CTR_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -141,6 +147,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Arcfour_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -157,7 +164,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -179,7 +187,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for AesCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void AesCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -192,7 +201,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 8 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Arc4CipherTest.cs

@@ -16,7 +16,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for Arc4Cipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void Arc4CipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -55,7 +56,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -119,7 +121,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -139,6 +142,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Arcfour128_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -155,6 +159,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Arcfour256_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);

+ 7 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/BlowfishCipherTest.cs

@@ -30,6 +30,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_BlowfishCBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -46,7 +47,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for BlowfishCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void BlowfishCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -59,7 +61,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -81,7 +84,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 7 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CastCipherTest.cs

@@ -30,6 +30,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_Cast128CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -45,7 +46,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for CastCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void CastCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -58,7 +60,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -80,7 +83,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 7 - 6
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherModeTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
 {
     /// <summary>
     ///This is a test class for CipherModeTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value
@@ -41,7 +41,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             CipherMode target = CreateCipherMode(); // TODO: Initialize to an appropriate value

+ 5 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/CipherPaddingTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
 {
     /// <summary>
     ///This is a test class for CipherPaddingTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Pad
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PadTest()
         {
             CipherPadding target = CreateCipherPadding(); // TODO: Initialize to an appropriate value

+ 6 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/DesCipherTest.cs

@@ -13,7 +13,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DesCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DesCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -26,7 +27,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -48,7 +50,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 7 - 6
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CbcCipherModeTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
 {
     /// <summary>
     ///This is a test class for CbcCipherModeTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -35,7 +35,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value

+ 9 - 7
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CfbCipherModeTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
 {
     /// <summary>
     ///This is a test class for CfbCipherModeTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -35,7 +35,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -55,7 +56,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for CfbCipherMode Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void CfbCipherModeConstructorTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value

+ 9 - 7
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/CtrCipherModeTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
 {
     /// <summary>
     ///This is a test class for CtrCipherModeTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -35,7 +35,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -55,7 +56,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for CtrCipherMode Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void CtrCipherModeConstructorTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value

+ 9 - 7
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Modes/OfbCipherModeTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Modes
 {
     /// <summary>
     ///This is a test class for OfbCipherModeTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -35,7 +35,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value
@@ -55,7 +56,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for OfbCipherMode Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void OfbCipherModeConstructorTest()
         {
             byte[] iv = null; // TODO: Initialize to an appropriate value

+ 5 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS5PaddingTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
 {
     /// <summary>
     ///This is a test class for PKCS5PaddingTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Pad
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PadTest()
         {
             PKCS5Padding target = new PKCS5Padding(); // TODO: Initialize to an appropriate value

+ 5 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/Paddings/PKCS7PaddingTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
 {
     /// <summary>
     ///This is a test class for PKCS7PaddingTest and is intended
@@ -15,7 +14,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Pad
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void PadTest()
         {
             PKCS7Padding target = new PKCS7Padding(); // TODO: Initialize to an appropriate value

+ 6 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/RsaCipherTest.cs

@@ -14,7 +14,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for RsaCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void RsaCipherConstructorTest()
         {
             RsaKey key = null; // TODO: Initialize to an appropriate value
@@ -25,7 +26,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for Decrypt
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptTest()
         {
             RsaKey key = null; // TODO: Initialize to an appropriate value
@@ -41,7 +43,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for Encrypt
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptTest()
         {
             RsaKey key = null; // TODO: Initialize to an appropriate value

+ 6 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/SerpentCipherTest.cs

@@ -13,7 +13,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for SerpentCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SerpentCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -26,7 +27,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -48,7 +50,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 7 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TripleDesCipherTest.cs

@@ -30,6 +30,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         [TestMethod]
         [Owner("olegkap")]
         [TestCategory("Cipher")]
+        [TestCategory("integration")]
         public void Test_Cipher_TripleDESCBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -45,7 +46,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for TripleDesCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void TripleDesCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -58,7 +60,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -80,7 +83,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 6 - 3
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/TwofishCipherTest.cs

@@ -13,7 +13,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for TwofishCipher Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void TwofishCipherConstructorTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -26,7 +27,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value
@@ -48,7 +50,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             byte[] key = null; // TODO: Initialize to an appropriate value

+ 7 - 6
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DigitalSignatureTest.cs

@@ -1,9 +1,8 @@
-using Renci.SshNet.Security.Cryptography;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Security.Cryptography;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
 {
     /// <summary>
     ///This is a test class for DigitalSignatureTest and is intended
@@ -22,7 +21,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Sign
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SignTest()
         {
             DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value
@@ -37,7 +37,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for Verify
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void VerifyTest()
         {
             DigitalSignature target = CreateDigitalSignature(); // TODO: Initialize to an appropriate value

+ 8 - 4
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaDigitalSignatureTest.cs

@@ -14,7 +14,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for DsaDigitalSignature Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DsaDigitalSignatureConstructorTest()
         {
             DsaKey key = null; // TODO: Initialize to an appropriate value
@@ -25,7 +26,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             DsaKey key = null; // TODO: Initialize to an appropriate value
@@ -37,7 +39,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for Sign
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void SignTest()
         {
             DsaKey key = null; // TODO: Initialize to an appropriate value
@@ -53,7 +56,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for Verify
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void VerifyTest()
         {
             DsaKey key = null; // TODO: Initialize to an appropriate value

+ 143 - 5
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/DsaKeyTest.cs

@@ -1,13 +1,151 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Renci.SshNet.Common;
+using Renci.SshNet.Security;
 using Renci.SshNet.Tests.Common;
 
-namespace Renci.SshNet.Tests.Classes.Security
+namespace Renci.SshNet.Tests.Classes.Security.Cryptography
 {
     /// <summary>
-    /// Contains DSA private and public key
-    /// </summary>
-    [TestClass]
+    ///This is a test class for DsaKeyTest and is intended
+    ///to contain all DsaKeyTest Unit Tests
+    ///</summary>
+    [TestClass()]
     public class DsaKeyTest : TestBase
     {
+        /// <summary>
+        ///A test for DsaKey Constructor
+        ///</summary>
+        [TestMethod()]
+        public void DsaKeyConstructorTest()
+        {
+            DsaKey target = new DsaKey();
+            Assert.Inconclusive("TODO: Implement code to verify target");
+        }
+
+        /// <summary>
+        ///A test for DsaKey Constructor
+        ///</summary>
+        [TestMethod]
+        [Ignore] // placeholder for actual test
+        public void DsaKeyConstructorTest1()
+        {
+            byte[] data = null; // TODO: Initialize to an appropriate value
+            DsaKey target = new DsaKey(data);
+            Assert.Inconclusive("TODO: Implement code to verify target");
+        }
+
+        /// <summary>
+        ///A test for DsaKey Constructor
+        ///</summary>
+        [TestMethod()]
+        public void DsaKeyConstructorTest2()
+        {
+            BigInteger p = new BigInteger(); // TODO: Initialize to an appropriate value
+            BigInteger q = new BigInteger(); // TODO: Initialize to an appropriate value
+            BigInteger g = new BigInteger(); // TODO: Initialize to an appropriate value
+            BigInteger y = new BigInteger(); // TODO: Initialize to an appropriate value
+            BigInteger x = new BigInteger(); // TODO: Initialize to an appropriate value
+            DsaKey target = new DsaKey(p, q, g, y, x);
+            Assert.Inconclusive("TODO: Implement code to verify target");
+        }
+
+        /// <summary>
+        ///A test for Dispose
+        ///</summary>
+        [TestMethod()]
+        public void DisposeTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            target.Dispose();
+            Assert.Inconclusive("A method that does not return a value cannot be verified.");
+        }
+
+        /// <summary>
+        ///A test for G
+        ///</summary>
+        [TestMethod()]
+        public void GTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger actual;
+            actual = target.G;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for KeyLength
+        ///</summary>
+        [TestMethod()]
+        public void KeyLengthTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            int actual;
+            actual = target.KeyLength;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for P
+        ///</summary>
+        [TestMethod()]
+        public void PTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger actual;
+            actual = target.P;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for Public
+        ///</summary>
+        [TestMethod]
+        [Ignore] // placeholder for actual test
+        public void PublicTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger[] expected = null; // TODO: Initialize to an appropriate value
+            BigInteger[] actual;
+            target.Public = expected;
+            actual = target.Public;
+            Assert.AreEqual(expected, actual);
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for Q
+        ///</summary>
+        [TestMethod()]
+        public void QTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger actual;
+            actual = target.Q;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for X
+        ///</summary>
+        [TestMethod()]
+        public void XTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger actual;
+            actual = target.X;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
+
+        /// <summary>
+        ///A test for Y
+        ///</summary>
+        [TestMethod()]
+        public void YTest()
+        {
+            DsaKey target = new DsaKey(); // TODO: Initialize to an appropriate value
+            BigInteger actual;
+            actual = target.Y;
+            Assert.Inconclusive("Verify the correctness of this test method.");
+        }
     }
-}
+}

+ 8 - 0
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/HMacTest.cs

@@ -15,6 +15,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
     public class HMacTest : TestBase
     {
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_MD5_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -29,6 +30,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_Sha1_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -43,6 +45,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_MD5_96_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -57,6 +60,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_Sha1_96_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -71,6 +75,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_Sha256_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -85,6 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_Sha256_96_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -99,6 +105,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_RIPEMD160_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
@@ -113,6 +120,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         }
 
         [TestMethod]
+        [TestCategory("integration")]
         public void Test_HMac_RIPEMD160_OPENSSH_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);

+ 4 - 2
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/RsaDigitalSignatureTest.cs

@@ -15,7 +15,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for RsaDigitalSignature Constructor
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void RsaDigitalSignatureConstructorTest()
         {
             RsaKey rsaKey = null; // TODO: Initialize to an appropriate value
@@ -26,7 +27,8 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
         /// <summary>
         ///A test for Dispose
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DisposeTest()
         {
             RsaKey rsaKey = null; // TODO: Initialize to an appropriate value

+ 4 - 2
Renci.SshClient/Renci.SshNet.Tests/Classes/Security/Cryptography/SymmetricCipherTest.cs

@@ -22,7 +22,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for DecryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void DecryptBlockTest()
         {
             SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value
@@ -41,7 +42,8 @@ namespace Renci.SshNet.Tests
         /// <summary>
         ///A test for EncryptBlock
         ///</summary>
-        [TestMethod()]
+        [TestMethod]
+        [Ignore] // placeholder for actual test
         public void EncryptBlockTest()
         {
             SymmetricCipher target = CreateSymmetricCipher(); // TODO: Initialize to an appropriate value

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác