8
8
using System . Net ;
9
9
using System . Net . Sockets ;
10
10
using System . Text ;
11
- using System . Threading ;
12
11
13
12
namespace Renci . SshNet . Tests . Classes . Connection
14
13
{
15
14
[ TestClass ]
16
- public class ProtocolVersionExchangeTest_ServerDoesNotRespondWithIdentificationStringBeforeTimeout
15
+ public class ProtocolVersionExchangeTest_TimeoutReadingIdentificationString
17
16
{
18
17
private AsyncSocketListener _server ;
19
18
private ProtocolVersionExchange _protocolVersionExchange ;
20
19
private string _clientVersion ;
21
20
private TimeSpan _timeout ;
22
21
private IPEndPoint _serverEndPoint ;
23
22
private List < byte > _dataReceivedByServer ;
24
- private byte [ ] _serverIdentification ;
25
23
private bool _clientDisconnected ;
26
24
private Socket _client ;
27
- private SshIdentification _actual ;
28
25
private SshOperationTimeoutException _actualException ;
29
26
30
27
[ TestInitialize ]
@@ -45,7 +42,6 @@ public void Cleanup()
45
42
46
43
if ( _client != null )
47
44
{
48
- _client . Shutdown ( SocketShutdown . Both ) ;
49
45
_client . Close ( ) ;
50
46
_client = null ;
51
47
}
@@ -57,18 +53,14 @@ protected void Arrange()
57
53
_timeout = TimeSpan . FromMilliseconds ( 200 ) ;
58
54
_serverEndPoint = new IPEndPoint ( IPAddress . Loopback , 8122 ) ;
59
55
_dataReceivedByServer = new List < byte > ( ) ;
60
- _serverIdentification = Encoding . UTF8 . GetBytes ( "SSH-Zero-OurSSHAppliance \r \n !" ) ;
56
+ _clientDisconnected = false ;
61
57
62
58
_server = new AsyncSocketListener ( _serverEndPoint ) ;
63
59
_server . Start ( ) ;
64
60
_server . BytesReceived += ( bytes , socket ) =>
65
61
{
66
62
_dataReceivedByServer . AddRange ( bytes ) ;
67
63
socket . Send ( Encoding . UTF8 . GetBytes ( "Welcome!\r \n " ) ) ;
68
- /*
69
- Thread.Sleep(_timeout.Add(TimeSpan.FromMilliseconds(50)));
70
- socket.Shutdown(SocketShutdown.Send);
71
- */
72
64
} ;
73
65
_server . Disconnected += ( socket ) => _clientDisconnected = true ;
74
66
@@ -112,16 +104,10 @@ public void ClientIdentificationWasSentToServer()
112
104
}
113
105
114
106
[ TestMethod ]
115
- public void ConnectionIsClosedByServer ( )
107
+ public void ClientSocketShouldBeConnected ( )
116
108
{
117
109
Assert . IsTrue ( _client . Connected ) ;
118
110
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 ) ;
125
111
}
126
112
}
127
113
}
0 commit comments