minor fix for bug 9520:
[mono.git] / mcs / class / corlib / Test / System.Globalization / RegionInfoTest.cs
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]
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]
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]
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                 public void CurrentRegion ()
65                 {
66                         Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion");
67                 }
68                 
69                 [Test]
70                 public void HongKong ()
71                 {
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");
83                 }
84
85                 [Test]
86                 public void Equals ()
87                 {
88                         var a = new RegionInfo (0x414);
89                         var b = new RegionInfo (0x43B);
90                         Assert.AreEqual (a, b);
91                 }
92         }
93 }