From: Katelyn Gadd Date: Wed, 29 Jul 2020 05:56:41 +0000 (-0700) Subject: Assert that we don't get the value we don't want instead of attempting to check for... X-Git-Tag: submit/tizen/20210909.063632~6359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ffdb13cb27c59062b8bec0f4080042468748c20;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Assert that we don't get the value we don't want instead of attempting to check for a specific error code. Fixes #39955 (#40019) --- diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index e685805..2c330cb 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -73,8 +73,11 @@ namespace System.IO.Tests // Make sure we're returning the native error as expected (and not the PAL error on Unix) using (LastError le = new LastError(Path.GetRandomFileName())) { - // Conveniently ERROR_FILE_NOT_FOUND and ENOENT are both 0x2 - Assert.Equal(2, le.Error); + // while ERROR_FILE_NOT_FOUND/ENOENT have predictable values on Windows, Linux and Mac, + // we can't rely on ENOENT having the same value on other platforms. Instead, assert + // that we didn't get the PAL error because we know its value. + const int PAL_Error_ENOENT = 0x1002D; + Assert.NotEqual(PAL_Error_ENOENT, le.Error); } }