Skip to content

Commit 532dac4

Browse files
committed
Harden test.
1 parent 1d5d58e commit 532dac4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortStarted_ChannelBound.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,23 @@ public void ForwardedPortShouldRefuseNewConnections()
165165
[TestMethod]
166166
public void BoundClientShouldNotBeClosed()
167167
{
168-
// the forwarded port itself does not close the client connection when the channel is closed properly
168+
// the forwarded port itself does not close the client connection; when the channel is closed properly
169169
// it's the channel that will take care of closing the client connection
170-
_client.Send(new byte[] { 0x0a }, 0, 1, SocketFlags.None);
170+
//
171+
// we'll check if the client connection is still alive by attempting to receive, which should time out
172+
// as the forwarded port (or its channel) are not sending anything
173+
174+
var buffer = new byte[1];
175+
176+
try
177+
{
178+
_client.Receive(buffer);
179+
Assert.Fail();
180+
}
181+
catch (SocketException ex)
182+
{
183+
Assert.AreEqual(SocketError.TimedOut, ex.SocketErrorCode);
184+
}
171185
}
172186

173187
[TestMethod]

0 commit comments

Comments
 (0)