From 55e6177e7b43aa84e6cc834991aa7bc9349a593c Mon Sep 17 00:00:00 2001 From: Scott Xu Date: Sun, 10 Mar 2024 09:49:14 +0800 Subject: [PATCH] Use BCL Timeout --- src/Renci.SshNet/BaseClient.cs | 6 +++--- src/Renci.SshNet/Connection/ConnectorBase.cs | 4 ++-- src/Renci.SshNet/NetConfClient.cs | 3 ++- src/Renci.SshNet/ScpClient.cs | 3 ++- src/Renci.SshNet/Session.cs | 18 +----------------- src/Renci.SshNet/SftpClient.cs | 2 +- src/Renci.SshNet/SshCommand.cs | 2 +- ..._Connected_KeepAlivesNotSentConcurrently.cs | 2 +- .../Classes/Channels/ChannelDirectTcpipTest.cs | 6 +++--- .../Classes/Common/CountdownEventTest.cs | 8 ++++---- .../SessionTest_ConnectToServerFails.cs | 6 +++--- .../Classes/SessionTest_Connected.cs | 4 ++-- .../SessionTest_Connected_ConnectionReset.cs | 6 +++--- .../SessionTest_Connected_Disconnect.cs | 6 +++--- ...ssionTest_Connected_ServerSendsBadPacket.cs | 6 +++--- ...t_Connected_ServerSendsDisconnectMessage.cs | 6 +++--- ...SendsDisconnectMessageAndShutsDownSocket.cs | 4 ++-- ...nected_ServerSendsUnsupportedMessageType.cs | 4 ++-- ...hutsDownSendAfterSendingIncompletePacket.cs | 6 +++--- ...sionTest_Connected_ServerShutsDownSocket.cs | 6 +++--- .../Classes/SessionTest_NotConnected.cs | 6 +++--- 21 files changed, 50 insertions(+), 64 deletions(-) diff --git a/src/Renci.SshNet/BaseClient.cs b/src/Renci.SshNet/BaseClient.cs index 9d60d84ea..db11a6178 100644 --- a/src/Renci.SshNet/BaseClient.cs +++ b/src/Renci.SshNet/BaseClient.cs @@ -108,7 +108,7 @@ public TimeSpan KeepAliveInterval return; } - if (value == SshNet.Session.InfiniteTimeSpan) + if (value == Timeout.InfiniteTimeSpan) { // stop the timer when the value is -1 milliseconds StopKeepAliveTimer(); @@ -196,7 +196,7 @@ private protected BaseClient(ConnectionInfo connectionInfo, bool ownsConnectionI ConnectionInfo = connectionInfo; _ownsConnectionInfo = ownsConnectionInfo; _serviceFactory = serviceFactory; - _keepAliveInterval = SshNet.Session.InfiniteTimeSpan; + _keepAliveInterval = Timeout.InfiniteTimeSpan; } /// @@ -508,7 +508,7 @@ private void SendKeepAliveMessage() /// private void StartKeepAliveTimer() { - if (_keepAliveInterval == SshNet.Session.InfiniteTimeSpan) + if (_keepAliveInterval == Timeout.InfiniteTimeSpan) { return; } diff --git a/src/Renci.SshNet/Connection/ConnectorBase.cs b/src/Renci.SshNet/Connection/ConnectorBase.cs index 384091b18..c1b30fb8f 100644 --- a/src/Renci.SshNet/Connection/ConnectorBase.cs +++ b/src/Renci.SshNet/Connection/ConnectorBase.cs @@ -103,7 +103,7 @@ protected async Task SocketConnectAsync(string host, int port, Cancellat protected static byte SocketReadByte(Socket socket) { var buffer = new byte[1]; - _ = SocketRead(socket, buffer, 0, 1, Session.InfiniteTimeSpan); + _ = SocketRead(socket, buffer, 0, 1, Timeout.InfiniteTimeSpan); return buffer[0]; } @@ -128,7 +128,7 @@ protected static byte SocketReadByte(Socket socket, TimeSpan readTimeout) /// The read failed. protected static int SocketRead(Socket socket, byte[] buffer, int offset, int length) { - return SocketRead(socket, buffer, offset, length, Session.InfiniteTimeSpan); + return SocketRead(socket, buffer, offset, length, Timeout.InfiniteTimeSpan); } /// diff --git a/src/Renci.SshNet/NetConfClient.cs b/src/Renci.SshNet/NetConfClient.cs index a15a99e58..49be11766 100644 --- a/src/Renci.SshNet/NetConfClient.cs +++ b/src/Renci.SshNet/NetConfClient.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Net; +using System.Threading; using System.Xml; using Renci.SshNet.Common; @@ -149,7 +150,7 @@ private NetConfClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo) internal NetConfClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory) { - _operationTimeout = SshNet.Session.Infinite; + _operationTimeout = Timeout.Infinite; AutomaticMessageIdHandling = true; } diff --git a/src/Renci.SshNet/ScpClient.cs b/src/Renci.SshNet/ScpClient.cs index 507cf0a04..7aa57c62b 100644 --- a/src/Renci.SshNet/ScpClient.cs +++ b/src/Renci.SshNet/ScpClient.cs @@ -5,6 +5,7 @@ using System.IO; using System.Net; using System.Text.RegularExpressions; +using System.Threading; using Renci.SshNet.Channels; using Renci.SshNet.Common; @@ -211,7 +212,7 @@ private ScpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo) internal ScpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory) { - OperationTimeout = SshNet.Session.InfiniteTimeSpan; + OperationTimeout = Timeout.InfiniteTimeSpan; BufferSize = 1024 * 16; _remotePathTransformation = serviceFactory.CreateRemotePathDoubleQuoteTransformation(); } diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index 37b7f2db3..0c067ec2d 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -30,14 +30,6 @@ public class Session : ISession internal const byte CarriageReturn = 0x0d; internal const byte LineFeed = 0x0a; - /// - /// Specifies an infinite waiting period. - /// - /// - /// The value of this field is -1. - /// - internal const int Infinite = -1; - /// /// Specifies maximum packet size defined by the protocol. /// @@ -74,14 +66,6 @@ public class Session : ISession /// private const int LocalChannelDataPacketSize = 1024 * 64; - /// - /// Specifies an infinite waiting period. - /// - /// - /// The value of this field is -1 millisecond. - /// - internal static readonly TimeSpan InfiniteTimeSpan = new TimeSpan(0, 0, 0, 0, -1); - /// /// Holds the factory to use for creating new services. /// @@ -1895,7 +1879,7 @@ private bool IsSocketConnected() /// The read failed. private static int TrySocketRead(Socket socket, byte[] buffer, int offset, int length) { - return SocketAbstraction.Read(socket, buffer, offset, length, InfiniteTimeSpan); + return SocketAbstraction.Read(socket, buffer, offset, length, Timeout.InfiniteTimeSpan); } /// diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs index 7d2c62165..e9a73c484 100644 --- a/src/Renci.SshNet/SftpClient.cs +++ b/src/Renci.SshNet/SftpClient.cs @@ -259,7 +259,7 @@ private SftpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo) internal SftpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory) { - _operationTimeout = SshNet.Session.Infinite; + _operationTimeout = Timeout.Infinite; _bufferSize = 1024 * 32; } diff --git a/src/Renci.SshNet/SshCommand.cs b/src/Renci.SshNet/SshCommand.cs index b348c4ec9..58b1942cc 100644 --- a/src/Renci.SshNet/SshCommand.cs +++ b/src/Renci.SshNet/SshCommand.cs @@ -184,7 +184,7 @@ internal SshCommand(ISession session, string commandText, Encoding encoding) _session = session; CommandText = commandText; _encoding = encoding; - CommandTimeout = Session.InfiniteTimeSpan; + CommandTimeout = Timeout.InfiniteTimeSpan; _sessionErrorOccuredWaitHandle = new AutoResetEvent(initialState: false); _session.Disconnected += Session_Disconnected; diff --git a/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAlivesNotSentConcurrently.cs b/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAlivesNotSentConcurrently.cs index ac0539e98..c03251026 100644 --- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAlivesNotSentConcurrently.cs +++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_Connected_KeepAlivesNotSentConcurrently.cs @@ -70,7 +70,7 @@ protected override void Act() Thread.Sleep(200); // disable further keep-alives - _client.KeepAliveInterval = Session.InfiniteTimeSpan; + _client.KeepAliveInterval = Timeout.InfiniteTimeSpan; // wait until keep-alive has been sent at least once Assert.IsTrue(_keepAliveSent.WaitOne(500)); diff --git a/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs b/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs index 649f6a4f1..e3daf22f6 100644 --- a/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs +++ b/test/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest.cs @@ -66,7 +66,7 @@ public void SocketShouldBeClosedAndBindShouldEndWhenForwardedPortSignalsClosingE _remotePacketSize, _remoteChannelNumber)))); _ = _sessionMock.Setup(p => p.WaitOnHandle(It.IsAny())) - .Callback(p => p.WaitOne(Session.Infinite)); + .Callback(p => p.WaitOne()); var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122); using (var localPortListener = new AsyncSocketListener(localPortEndPoint)) @@ -122,7 +122,7 @@ public void SocketShouldBeClosedAndBindShouldEndWhenOnErrorOccurredIsInvoked() _remotePacketSize, _remoteChannelNumber)))); _ = _sessionMock.Setup(p => p.WaitOnHandle(It.IsAny())) - .Callback(p => p.WaitOne(Session.Infinite)); + .Callback(p => p.WaitOne()); var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122); using (var localPortListener = new AsyncSocketListener(localPortEndPoint)) @@ -183,7 +183,7 @@ public void SocketShouldBeClosedAndEofShouldBeSentToServerWhenClientShutsDownSoc _remoteChannelNumber)))); _ = _sessionMock.InSequence(sequence) .Setup(p => p.WaitOnHandle(It.IsAny())) - .Callback(p => p.WaitOne(Session.Infinite)); + .Callback(p => p.WaitOne()); _ = _sessionMock.InSequence(sequence) .Setup(p => p.IsConnected) .Returns(true); diff --git a/test/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs b/test/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs index 427e07ccf..12d927a90 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs @@ -89,7 +89,7 @@ public void Signal_CurrentCountZero() public void Wait_TimeoutInfinite_ShouldBlockUntilCountdownEventIsSet() { var sleep = TimeSpan.FromMilliseconds(100); - var timeout = Session.InfiniteTimeSpan; + var timeout = Timeout.InfiniteTimeSpan; var countdownEvent = CreateCountdownEvent(1); var signalCount = 0; @@ -205,7 +205,7 @@ public void Wait_ShouldReturnFalseWhenTimeoutExpiresBeforeCountdownEventIsSet() Assert.IsFalse(countdownEvent.IsSet); Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0)); - _ = countdownEvent.Wait(Session.InfiniteTimeSpan); + _ = countdownEvent.Wait(Timeout.InfiniteTimeSpan); countdownEvent.Dispose(); } @@ -225,7 +225,7 @@ public void WaitHandle_ShouldAlwaysReturnSameInstance() public void WaitHandle_WaitOne_TimeoutInfinite_ShouldBlockUntilCountdownEventIsSet() { var sleep = TimeSpan.FromMilliseconds(100); - var timeout = Session.InfiniteTimeSpan; + var timeout = Timeout.InfiniteTimeSpan; var countdownEvent = CreateCountdownEvent(1); var signalCount = 0; @@ -341,7 +341,7 @@ public void WaitHandle_WaitOne_ShouldReturnFalseWhenTimeoutExpiresBeforeCountdow Assert.IsFalse(countdownEvent.IsSet); Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0)); - _ = countdownEvent.Wait(Session.InfiniteTimeSpan); + _ = countdownEvent.Wait(Timeout.InfiniteTimeSpan); countdownEvent.Dispose(); } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectToServerFails.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectToServerFails.cs index 16cfbb1ed..1950f2759 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectToServerFails.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_ConnectToServerFails.cs @@ -155,7 +155,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession)_session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -166,7 +166,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession)_session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); @@ -242,7 +242,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullEx try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (ArgumentNullException ex) diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs index e4f7f2430..cdc95c12e 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs @@ -203,7 +203,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldThrowArgumentNullExcepti try { - _ = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + _ = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (ArgumentNullException ex) @@ -246,7 +246,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldThrowArgumen try { - session.TryWait(waitHandle, Session.InfiniteTimeSpan, out exception); + session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out exception); Assert.Fail(); } catch (ArgumentNullException ex) diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs index fb49e66e8..59f9d4aac 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs @@ -160,7 +160,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -177,7 +177,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -188,7 +188,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs index 3b0c9b554..444a8d51a 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_Disconnect.cs @@ -156,7 +156,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -173,7 +173,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -184,7 +184,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs index c1f0fb5b2..b7c49b8bf 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsBadPacket.cs @@ -180,7 +180,7 @@ public void ISession_WaitOnHandleAndTimeout_WaitHandle_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -197,7 +197,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -208,7 +208,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs index 7000a2233..440e5879b 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessage.cs @@ -181,7 +181,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -202,7 +202,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -213,7 +213,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs index b91832a40..0a040bbd1 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsDisconnectMessageAndShutsDownSocket.cs @@ -183,7 +183,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -194,7 +194,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsUnsupportedMessageType.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsUnsupportedMessageType.cs index a748eae43..b69f61df0 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsUnsupportedMessageType.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerSendsUnsupportedMessageType.cs @@ -195,7 +195,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnFailed() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Failed, result); } @@ -206,7 +206,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnFailed var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Failed, result); Assert.IsNotNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSendAfterSendingIncompletePacket.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSendAfterSendingIncompletePacket.cs index 23db91667..0e4e0a91e 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSendAfterSendingIncompletePacket.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSendAfterSendingIncompletePacket.cs @@ -174,7 +174,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -191,7 +191,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -202,7 +202,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs index 00a8cd546..a2abe735a 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connected_ServerShutsDownSocket.cs @@ -167,7 +167,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (SshConnectionException ex) @@ -183,7 +183,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -213,7 +213,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) Session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs index 04491fbc7..4bd134348 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_NotConnected.cs @@ -125,7 +125,7 @@ public void ISession_TryWait_WaitHandleAndTimeout_ShouldReturnDisconnected() var session = (ISession) _session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan); Assert.AreEqual(WaitResult.Disconnected, result); } @@ -136,7 +136,7 @@ public void ISession_TryWait_WaitHandleAndTimeoutAndException_ShouldReturnDiscon var session = (ISession) _session; var waitHandle = new ManualResetEvent(false); - var result = session.TryWait(waitHandle, Session.InfiniteTimeSpan, out var exception); + var result = session.TryWait(waitHandle, Timeout.InfiniteTimeSpan, out var exception); Assert.AreEqual(WaitResult.Disconnected, result); Assert.IsNull(exception); @@ -212,7 +212,7 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowArgumentNullEx try { - session.WaitOnHandle(waitHandle, Session.InfiniteTimeSpan); + session.WaitOnHandle(waitHandle, Timeout.InfiniteTimeSpan); Assert.Fail(); } catch (ArgumentNullException ex)