88using System . Net ;
99using System . Net . Sockets ;
1010using System . Text ;
11- using System . Threading ;
1211
1312namespace Renci . SshNet . Tests . Classes . Connection
1413{
1514 [ TestClass ]
16- public class ProtocolVersionExchangeTest_ServerDoesNotRespondWithIdentificationStringBeforeTimeout
15+ public class ProtocolVersionExchangeTest_TimeoutReadingIdentificationString
1716 {
1817 private AsyncSocketListener _server ;
1918 private ProtocolVersionExchange _protocolVersionExchange ;
2019 private string _clientVersion ;
2120 private TimeSpan _timeout ;
2221 private IPEndPoint _serverEndPoint ;
2322 private List < byte > _dataReceivedByServer ;
24- private byte [ ] _serverIdentification ;
2523 private bool _clientDisconnected ;
2624 private Socket _client ;
27- private SshIdentification _actual ;
2825 private SshOperationTimeoutException _actualException ;
2926
3027 [ TestInitialize ]
@@ -45,7 +42,6 @@ public void Cleanup()
4542
4643 if ( _client != null )
4744 {
48- _client . Shutdown ( SocketShutdown . Both ) ;
4945 _client . Close ( ) ;
5046 _client = null ;
5147 }
@@ -57,18 +53,14 @@ protected void Arrange()
5753 _timeout = TimeSpan . FromMilliseconds ( 200 ) ;
5854 _serverEndPoint = new IPEndPoint ( IPAddress . Loopback , 8122 ) ;
5955 _dataReceivedByServer = new List < byte > ( ) ;
60- _serverIdentification = Encoding . UTF8 . GetBytes ( "SSH-Zero-OurSSHAppliance \r \n !" ) ;
56+ _clientDisconnected = false ;
6157
6258 _server = new AsyncSocketListener ( _serverEndPoint ) ;
6359 _server . Start ( ) ;
6460 _server . BytesReceived += ( bytes , socket ) =>
6561 {
6662 _dataReceivedByServer . AddRange ( bytes ) ;
6763 socket . Send ( Encoding . UTF8 . GetBytes ( "Welcome!\r \n " ) ) ;
68- /*
69- Thread.Sleep(_timeout.Add(TimeSpan.FromMilliseconds(50)));
70- socket.Shutdown(SocketShutdown.Send);
71- */
7264 } ;
7365 _server . Disconnected += ( socket ) => _clientDisconnected = true ;
7466
@@ -112,16 +104,10 @@ public void ClientIdentificationWasSentToServer()
112104 }
113105
114106 [ TestMethod ]
115- public void ConnectionIsClosedByServer ( )
107+ public void ClientSocketShouldBeConnected ( )
116108 {
117109 Assert . IsTrue ( _client . Connected ) ;
118110 Assert . IsFalse ( _clientDisconnected ) ;
119-
120- var bytesReceived = _client . Receive ( new byte [ 1 ] ) ;
121- Assert . AreEqual ( 0 , bytesReceived ) ;
122-
123- Assert . IsTrue ( _client . Connected ) ;
124- Assert . IsFalse ( _clientDisconnected ) ;
125111 }
126112 }
127113}
0 commit comments