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

Some tests fail on my machine. #274

Closed arlm closed 4 years ago

arlm commented 8 years ago

My machine is setup to German language, so some of the tests, that do test the exception text fail on my machine due to different language on the Exception message. Is there an easy fix to setup the language/Culture during tests? It does happen when I use the build.cmd/build.ps1 scripts.

AArnott commented 8 years ago

Hmmm... We could force the culture to en in the test class constructor.

arlm commented 8 years ago

I will try that on my machine this week and see the result.

AArnott commented 8 years ago

FYI this can be done with code such as this:

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
arlm commented 8 years ago

OK. I use it on most of the things I develop. I tend to prefer to explicitly set the culture on everything that has no localization support so that the strings and formatting (dates, currency and numbers) don't play tricks on the user.

I just thought there could be a way to setup these on appveyor or some other configuration file or attribute instead of setting this on all instances before running on our tests.

AArnott commented 8 years ago

If there is such a way, I'm not aware of it.

vbfox commented 8 years ago

NUnit include this by default via attributes,

The same type of attribute can be written for XUnit to add this to individual tests. https://github.com/Humanizr/Humanizer/blob/dev/src/Humanizer.Tests.Shared/UseCultureAttribute.cs seem to be a sample of that but I didn't try it.

AArnott commented 4 years ago

Closing due to a workaround being available or lack of popular demand. This allows us to better focus on high impact issues. If you feel this is blocking you, you may add a comment here to explain why this should be prioritized.

Thank you for your understanding.