File: RegionInfoTest.cs

package info (click to toggle)
mono 6.14.1%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,282,732 kB
  • sloc: cs: 11,182,461; xml: 2,850,281; ansic: 699,123; cpp: 122,919; perl: 58,604; javascript: 30,841; asm: 21,845; makefile: 19,602; sh: 10,973; python: 4,772; pascal: 925; sql: 859; sed: 16; php: 1
file content (95 lines) | stat: -rw-r--r-- 2,251 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// System.Globalization.RegionInfoTest.cs
//
// Author:
// 	Atsushi Enomoto  <atsushi@ximian.com>
//
// (c) 2007 Novell, Inc. (http://www.novell.com)
//

using NUnit.Framework;
using System.IO;
using System;
using System.Globalization;
using System.Threading;

namespace MonoTests.System.Globalization
{
	[TestFixture]
	public class RegionInfoTest
	{
		[Test]
		public void RegionByName ()
		{
			string [] names = new string [] {
				"AR", "ES", "HK", "TW", "US"};

			foreach (string name in names)
				new RegionInfo (name);

		}

		[Test]
		public void RegionByWrongName ()
		{
			string [] names = new string [] {
				"en", "EN"};

			foreach (string name in names) {
				try {
					new RegionInfo (name);
					Assert.Fail ("should be invalid: " + name);
				} catch (ArgumentException) {
				}
			}

			try {
				new RegionInfo ("2342#");
				Assert.Fail ("#2");
			} catch (ArgumentException) {
			}
		}

		[Test]
		public void RegionByLocaleName ()
		{
			string [] names = new string [] {
				"en-US", "zh-TW"};

			foreach (string name in names)
				new RegionInfo (name);
		}
		
		[Test]
		// This can fail on systems where CultureInfo.CurrentCulture==null
		[Category ("NotWorking")]
		public void CurrentRegion ()
		{
			Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion");
		}
		
		[Test]
		public void HongKong ()
		{
			// https://bugzilla.xamarin.com/show_bug.cgi?id=3476
			RegionInfo hk = new RegionInfo ("HK");
			// subset that match in both .NET 4 (Win7) and Mono
			Assert.AreEqual (hk.CurrencyEnglishName, "Hong Kong Dollar", "CurrencyEnglishName");
			Assert.IsTrue (hk.IsMetric, "IsMetric");
			Assert.AreEqual (hk.ISOCurrencySymbol, "HKD", "ISOCurrencySymbol");
			Assert.AreEqual (hk.Name, "HK", "Name");
			Assert.AreEqual (hk.TwoLetterISORegionName, "HK", "TwoLetterISORegionName");
			// the bug messed the order leading to DisplayName used for TLA (mono returns String.Empty)
			Assert.IsTrue (hk.ThreeLetterISORegionName.Length <= 3, "ThreeLetterISORegionName");
			Assert.IsTrue (hk.ThreeLetterWindowsRegionName.Length <= 3, "ThreeLetterWindowsRegionName");
		}

		[Test]
		public void Equals ()
		{
			var a = new RegionInfo (0x414);
			var b = new RegionInfo (0x43B);
			Assert.AreEqual (a, b);
		}
	}
}