Skip to content

Commit c7a0ca9

Browse files
authored
Add another allowed SocketError value in tests (#1457)
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.
1 parent 64d67cd commit c7a0ca9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_HostNameInvalid.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void ConnectShouldHaveThrownSocketException()
4444
{
4545
Assert.IsNotNull(_actualException);
4646
Assert.IsNull(_actualException.InnerException);
47-
Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
47+
Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData);
4848
}
4949
}
5050
}

test/Renci.SshNet.Tests/Classes/Connection/HttpConnectorTest_Connect_ProxyHostInvalid.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void ConnectShouldHaveThrownSocketException()
5252
{
5353
Assert.IsNotNull(_actualException);
5454
Assert.IsNull(_actualException.InnerException);
55-
Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
55+
Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData);
5656
}
5757
}
5858
}

test/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Connect_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostN
2121
}
2222
catch (SocketException ex)
2323
{
24-
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
24+
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData);
2525
}
2626
}
2727

@@ -39,7 +39,7 @@ public void Connect_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCode
3939
}
4040
catch (SocketException ex)
4141
{
42-
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
42+
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData);
4343
}
4444
}
4545
}

0 commit comments

Comments
 (0)