2 // System.Globalization.RegionInfoTest.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (c) 2007 Novell, Inc. (http://www.novell.com)
10 using NUnit.Framework;
13 using System.Globalization;
14 using System.Threading;
16 namespace MonoTests.System.Globalization
19 public class RegionInfoTest
22 public void RegionByName ()
24 string [] names = new string [] {
25 "AR", "ES", "HK", "TW", "US"};
27 foreach (string name in names)
28 new RegionInfo (name);
33 public void RegionByWrongName ()
35 string [] names = new string [] {
38 foreach (string name in names) {
40 new RegionInfo (name);
41 Assert.Fail ("should be invalid: " + name);
42 } catch (ArgumentException) {
47 new RegionInfo ("2342#");
49 } catch (ArgumentException) {
54 public void RegionByLocaleName ()
56 string [] names = new string [] {
59 foreach (string name in names)
60 new RegionInfo (name);
64 // This can fail on systems where CultureInfo.CurrentCulture==null
65 [Category ("NotWorking")]
66 public void CurrentRegion ()
68 Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion");
72 public void HongKong ()
74 // https://bugzilla.xamarin.com/show_bug.cgi?id=3476
75 RegionInfo hk = new RegionInfo ("HK");
76 // subset that match in both .NET 4 (Win7) and Mono
77 Assert.AreEqual (hk.CurrencyEnglishName, "Hong Kong Dollar", "CurrencyEnglishName");
78 Assert.IsTrue (hk.IsMetric, "IsMetric");
79 Assert.AreEqual (hk.ISOCurrencySymbol, "HKD", "ISOCurrencySymbol");
80 Assert.AreEqual (hk.Name, "HK", "Name");
81 Assert.AreEqual (hk.TwoLetterISORegionName, "HK", "TwoLetterISORegionName");
82 // the bug messed the order leading to DisplayName used for TLA (mono returns String.Empty)
83 Assert.IsTrue (hk.ThreeLetterISORegionName.Length <= 3, "ThreeLetterISORegionName");
84 Assert.IsTrue (hk.ThreeLetterWindowsRegionName.Length <= 3, "ThreeLetterWindowsRegionName");
90 var a = new RegionInfo (0x414);
91 var b = new RegionInfo (0x43B);
92 Assert.AreEqual (a, b);