From 47692cbfd7bcc327d52778a59814f09f38ca5005 Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Sat, 27 Jul 2024 10:02:46 +0200 Subject: [PATCH] Add another allowed SocketError value in tests These have started failing for me locally (Win11). SocketError.NoData means "The requested name or IP address was not found on the name server." which lines up with what we are testing here. --- .../Connection/DirectConnectorTest_Connect_HostNameInvalid.cs | 2 +- .../Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs | 2 +- test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_HostNameInvalid.cs b/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_HostNameInvalid.cs index 0a29d70d7..81a5ad228 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_HostNameInvalid.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_HostNameInvalid.cs @@ -44,7 +44,7 @@ public void ConnectShouldHaveThrownSocketException() { Assert.IsNotNull(_actualException); Assert.IsNull(_actualException.InnerException); - Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain); + Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData); } } } diff --git a/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs b/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs index bf9d37d41..000779d8d 100644 --- a/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs +++ b/test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs @@ -52,7 +52,7 @@ public void ConnectShouldHaveThrownSocketException() { Assert.IsNotNull(_actualException); Assert.IsNull(_actualException.InnerException); - Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain); + Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs index 499fc3045..f608ed24e 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs @@ -21,7 +21,7 @@ public void Connect_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostN } catch (SocketException ex) { - Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain); + Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData); } } @@ -39,7 +39,7 @@ public void Connect_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCode } catch (SocketException ex) { - Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain); + Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData); } } }