I can't for the life of me get this to work, and [SetCulture] appears to be working fine - so I can only assume it's a bug.
I've posted to the mailing list and started off the process of working out whether it is a bug or not, but for now - I need to have my tests runningĀ in the right culture, without any side effects on the other tests once a test has been complete.
Here is my hack to do that:
public class CultureContext : IDisposable
{
private CultureInfo mOldCulture;
public CultureContext(String cultureName)
{
mOldCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
}
public void Dispose()
{
System.Threading.Thread.CurrentThread.CurrentUICulture = mOldCulture;
}
}
The usage is as follows, within a test do:
using (new CultureContext("fr-FR"))
{
// Test code here
}
This will ensure that your test runs with the ui culture of "fr-FR", before resetting it to whatever it was before the test began. Not pretty, but it'll do until I work out if it's user error or a bug preventing NUnit from doing what I want it to do!