1 // 2 // System.Globalization.RegionInfoTest.cs 3 // 4 // Author: 5 // Atsushi Enomoto <atsushi@ximian.com> 6 // 7 // (c) 2007 Novell, Inc. (http://www.novell.com) 8 // 9 10 using NUnit.Framework; 11 using System.IO; 12 using System; 13 using System.Globalization; 14 using System.Threading; 15 16 namespace MonoTests.System.Globalization 17 { 18 [TestFixture] 19 public class RegionInfoTest 20 { 21 [Test] RegionByName()22 public void RegionByName () 23 { 24 string [] names = new string [] { 25 "AR", "ES", "HK", "TW", "US"}; 26 27 foreach (string name in names) 28 new RegionInfo (name); 29 30 } 31 32 [Test] RegionByWrongName()33 public void RegionByWrongName () 34 { 35 string [] names = new string [] { 36 "en", "EN"}; 37 38 foreach (string name in names) { 39 try { 40 new RegionInfo (name); 41 Assert.Fail ("should be invalid: " + name); 42 } catch (ArgumentException) { 43 } 44 } 45 46 try { 47 new RegionInfo ("2342#"); 48 Assert.Fail ("#2"); 49 } catch (ArgumentException) { 50 } 51 } 52 53 [Test] RegionByLocaleName()54 public void RegionByLocaleName () 55 { 56 string [] names = new string [] { 57 "en-US", "zh-TW"}; 58 59 foreach (string name in names) 60 new RegionInfo (name); 61 } 62 63 [Test] 64 // This can fail on systems where CultureInfo.CurrentCulture==null 65 [Category ("NotWorking")] CurrentRegion()66 public void CurrentRegion () 67 { 68 Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion"); 69 } 70 71 [Test] HongKong()72 public void HongKong () 73 { 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"); 85 } 86 87 [Test] Equals()88 public void Equals () 89 { 90 var a = new RegionInfo (0x414); 91 var b = new RegionInfo (0x43B); 92 Assert.AreEqual (a, b); 93 } 94 } 95 }