فهرست منبع

Use OS-agnostic socket error codes to allow tests run on different OSes (#1179)

SocketErrorCode is OS agnostic, ErrorCode is OS specific.

On Windows ErrorCode = (int) SocketErrorCode, but on Mac and Unix it is not.

For example ExitCode for HostNotFound (11001) on Windows is 11001, on Mac & Unix is -131073. So testing for ExitCode == 11001 fails on Mac & Unix.

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Dmitry Tsarevich 2 سال پیش
والد
کامیت
dd2e55209b
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      src/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs

+ 2 - 2
src/Renci.SshNet.Tests/Classes/SftpClientTest.Connect.cs

@@ -20,7 +20,7 @@ namespace Renci.SshNet.Tests.Classes
             }
             catch (SocketException ex)
             {
-                Assert.IsTrue(ex.ErrorCode is (int) SocketError.HostNotFound or (int) SocketError.TryAgain);
+                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
             }
         }
 
@@ -38,7 +38,7 @@ namespace Renci.SshNet.Tests.Classes
             }
             catch (SocketException ex)
             {
-                Assert.IsTrue(ex.ErrorCode is (int) SocketError.HostNotFound or (int) SocketError.TryAgain);
+                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
             }
         }
     }