It's a good idea, when unit-testing your classes, to test under multiple circumstances -- such as multiple cultures. Sure, a routine may work great when run under a given culture, say US English, but what if it is run on a Spanish or Japanese machine?
MbUnit makes it easy to run tests under different cultures. If NUnit is your tool of choice, you need to do a little bit more work.
First, let's start with MbUnit. This great unit-testing framework has a special attribute called MultipleCulture that automagically runs your tests under all the cultures you specify as a comma-separated list. Here's an example in C#:
[Test][MultipleCulture("en-US,es-ES,jp-JP")]
public void ConversionTest()
{
single price = MyConverter.FromCurrencyText("$ 200.00")
Assert.AreEqual(200, price)
}
NUnit, unfortunately, doesn't feature this attribute. But you can do almost the same if you create multiple unit-testing classes that inherit from a base class that contains all the tests. Every of these derived classes then sets a given culture on the thread, as in this example in Visual Basic.Net:
<TestFixture()> _
Public Class MyConverterJapaneseUnitTests
Inherits MyConverterUnitTests
<TestFixtureSetUp()> _
Public Sub Setup()
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("jp-JP")
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("jp-JP")
End Sub
End Class
Open your assembly with NUnit and voilà -- instant multicultural tests!