Skip to content

Commit 7d52787

Browse files
authored
make ConnectShouldActivateKeepAliveIfSessionIs test less flaky (#1410)
* make ConnectShouldActivateKeepAliveIfSessionIs test less flaky wait longer and expect at least two instead of exactly two. example: https://ci.appveyor.com/project/drieseng/ssh-net/builds/49849877/job/9rrtw6j8eu3i5p8o?fullLog=true * fix net462 build
1 parent b4722b8 commit 7d52787

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public void ConnectShouldActivateKeepAliveIfSessionIs()
6969

7070
_client.Connect();
7171

72-
// allow keep-alive to be sent twice
73-
Thread.Sleep(250);
72+
// allow keep-alive to be sent at least twice with some margin for error
73+
Thread.Sleep(5 * (int)_keepAliveInterval.TotalMilliseconds);
7474

75-
// Exactly two keep-alives should be sent
76-
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(2));
75+
// At least two keep-alives should be sent
76+
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.AtLeast(2));
7777
}
7878

7979
private class MyClient : BaseClient

0 commit comments

Comments
 (0)