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 public void CurrentRegion ()
66 Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion");
70 public void HongKong ()
72 // https://bugzilla.xamarin.com/show_bug.cgi?id=3476
73 RegionInfo hk = new RegionInfo ("HK");
74 // subset that match in both .NET 4 (Win7) and Mono
75 Assert.AreEqual (hk.CurrencyEnglishName, "Hong Kong Dollar", "CurrencyEnglishName");
76 Assert.IsTrue (hk.IsMetric, "IsMetric");
77 Assert.AreEqual (hk.ISOCurrencySymbol, "HKD", "ISOCurrencySymbol");
78 Assert.AreEqual (hk.Name, "HK", "Name");
79 Assert.AreEqual (hk.TwoLetterISORegionName, "HK", "TwoLetterISORegionName");
80 // the bug messed the order leading to DisplayName used for TLA (mono returns String.Empty)
81 Assert.IsTrue (hk.ThreeLetterISORegionName.Length <= 3, "ThreeLetterISORegionName");
82 Assert.IsTrue (hk.ThreeLetterWindowsRegionName.Length <= 3, "ThreeLetterWindowsRegionName");
88 var a = new RegionInfo (0x414);
89 var b = new RegionInfo (0x43B);
90 Assert.AreEqual (a, b);