diff options
Diffstat (limited to 'src/ProtocolBuffers.Test/TestUtil.cs')
-rw-r--r-- | src/ProtocolBuffers.Test/TestUtil.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ProtocolBuffers.Test/TestUtil.cs b/src/ProtocolBuffers.Test/TestUtil.cs index 3e89dd75..84756397 100644 --- a/src/ProtocolBuffers.Test/TestUtil.cs +++ b/src/ProtocolBuffers.Test/TestUtil.cs @@ -31,10 +31,12 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; using Google.ProtocolBuffers.TestProtos; using NUnit.Framework; +using System.Threading; namespace Google.ProtocolBuffers { internal static class TestUtil { @@ -1577,6 +1579,20 @@ namespace Google.ProtocolBuffers { } return goldenPackedFieldsMessage; } + + private static readonly string[] TestCultures = { "en-US", "en-GB", "fr-FR", "de-DE" }; + + public static void TestInMultipleCultures(Action test) { + CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; + foreach (string culture in TestCultures) { + try { + Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); + test(); + } finally { + Thread.CurrentThread.CurrentCulture = originalCulture; + } + } + } /// <summary> /// Helper to construct a byte array from a bunch of bytes. |