Use NUnit's SetCulture attribute rather than Culture
authorNiklas Therning <niklas@therning.org>
Fri, 16 Sep 2016 12:47:47 +0000 (14:47 +0200)
committerNiklas Therning <niklas@therning.org>
Fri, 16 Sep 2016 12:55:24 +0000 (14:55 +0200)
A few tests are currently ignored when running on a system where the default
culture isn't "en" or "en-US". This patch changes Culture attributes to
SetCulture attributes instead to make those tests run on all system and make
NUnit set the culture to the required one during the test run.

Also found and fixed a test failure in one of these methods,
DateTimeTest.ToUniversalTime_TimeZoneOffsetShouldNotOverflow(), which assumed
the minimum year is 0 while it's actually 1. Confirmed that this is the case
on .NET as well.

mcs/class/corlib/Test/System/DateTimeTest.cs
mcs/class/corlib/Test/System/DecimalTest-Microsoft.cs
mcs/class/corlib/Test/System/DoubleTest.cs

index a22b17ebb5b8d377d9314fbe848cc6434640dd2b..ae383e310dd76adc68a779e9969f1df4c7e0ffe5 100644 (file)
@@ -2646,7 +2646,7 @@ namespace MonoTests.System
                }
 
                [Test]
-               [Culture ("en-us")]
+               [SetCulture ("en-us")]
                public void ToUniversalTime_TimeZoneOffsetShouldNotOverflow ()
                {
                        var m = DateTime.MaxValue;
@@ -2662,7 +2662,7 @@ namespace MonoTests.System
                        res = m.ToUniversalTime ();
 
                        // It does not matter which time zone but we should never overflow or have DateTime.MinValue
-                       Assert.AreEqual (0, res.Year, "#10");
+                       Assert.AreEqual (1, res.Year, "#10");
                        Assert.AreEqual (1, res.Month, "#11");
                        Assert.AreEqual (1, res.Day, "#12");
                        Assert.AreEqual (DateTimeKind.Utc, res.Kind, "#13");
index 3ef265c7b4d82ac2d24fd7207a5d1b2141fcc518..261e9b5692537a0593711614e27b619b917e3637 100644 (file)
@@ -496,7 +496,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestParse()
                {
                    // Boolean Decimal.TryParse(String, NumberStyles, IFormatProvider, Decimal)
@@ -810,7 +810,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestToString()
                {
                    // String Decimal.ToString()
@@ -865,7 +865,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestNumberBufferLimit()
                {
                    Decimal dE = 1234567890123456789012345.6785m;
index 45d7ee110519c0c7a01f1d5e155b064f5f965eb0..81b2a5fdb2a45300da291b23c2e54d7a5714d113 100644 (file)
@@ -147,7 +147,7 @@ namespace MonoTests.System
                }
 
                [Test]
-               [Culture ("en-US")]
+               [SetCulture ("en-US")]
                public void Parse ()
                {
                        int i = 0;