dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

Fix test failures on non-English Windows machines #289

Closed arlm closed 7 years ago

arlm commented 8 years ago

I still have 10 tests failing when run on the Console through build.ps1 but it does not fail anymore inside Visual Studio.

The final tests results are on this gist: https://gist.github.com/arlm/1c610435639a2da47265914d9a0e2898

Fixes #274

arlm commented 8 years ago

Take a look on the commit now, please. I have aggregated all commits in one after doing the modifications you suggested.

AArnott commented 7 years ago

@arlm After the commit I just pushed, can you confirm the tests still pass for you?

arlm commented 7 years ago

We are still having problems with Win32 error messages:

The test is using the default locale for the machine. I doubt we can solve this without using GetMessge. It seems that as well as we are not calling it on Win32ErrorCode's constructor we get the default messages from .NET which comes from the .NET resources installed on the machine (in my case de-de) instead of using the locale for the current thread (en-US).

Failed   Kernel32ExtensionsFacts.ThrowOnError_Win32ErrorCode
Error Message:
   Assert.Equal() Failure
           (pos 0)
Expected: No action was taken as a system reboot is···
Actual:   Es wurde keine Aktion durchgeführt, da ei···
           (pos 0)
Stack Trace:
   bei Xunit.Assert.Equal(String expected, String actual, Boolean ignoreCase, Boolean ignoreLineEndingDifferences, Boolean ignoreWhiteSpaceDifferences) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\StringAsserts.cs:Zeile 239.
   bei Xunit.Assert.Equal(String expected, String actual) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\StringAsserts.cs:Zeile 169.
   bei Kernel32ExtensionsFacts.ThrowOnError_Win32ErrorCode() in C:\Users\amarcondes\Documents\GitHub\pinvoke\src\Kernel32.Tests.Shared\Kernel32ExtensionsFacts.cs:Zeile 25.
Failed   Win32ExceptionFacts.Win32Exception_Message
Error Message:
   Assert.Equal() Failure
           (pos 0)
Expected: Indicates a particular Security ID may no···
Actual:   Zeigt an, dass eine bestimmte Sicherheits···
           (pos 0)
Stack Trace:
   bei Xunit.Assert.Equal(String expected, String actual, Boolean ignoreCase, Boolean ignoreLineEndingDifferences, Boolean ignoreWhiteSpaceDifferences) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\StringAsserts.cs:Zeile 239.
   bei Xunit.Assert.Equal(String expected, String actual) in C:\BuildAgent\work\cb37e9acf085d108\src\xunit.assert\Asserts\StringAsserts.cs:Zeile 169.
   bei Win32ExceptionFacts.Win32Exception_Message() in C:\Users\amarcondes\Documents\GitHub\pinvoke\src\Kernel32.Tests.Shared\Win32ExceptionFacts.cs:Zeile 26.
arlm commented 7 years ago

Seems good to me. So I would close this as well as this fix has reached its maximum impact. Any further improvement involves other efforts that could be tracked as separated issues.