5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) 2006 Novell, Inc.
10 using NUnit.Framework;
12 using System.Collections.Generic;
14 using System.Reflection;
17 namespace MonoTests.System.Text
20 [Category ("MobileNotWorking")]
21 public class EncodingInfoTest
24 // The purpose of this test is to make sure that
25 // new encodings added to I18N are also listed in the
26 // returned array from Encoding.GetEncodings() so that
27 // we can make sure to put additional encodings into
28 // Encoding.GetEncodings() code.
29 public void EncodingGetEncodingsReturnsAll ()
31 // Make sure that those I18N assemblies are loaded.
32 string basePath = Assembly.GetAssembly (typeof (int)).CodeBase;
33 basePath = basePath.Substring (0, basePath.LastIndexOf ('/'));
34 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.West.dll"), "West");
35 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.CJK.dll"), "CJK");
36 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.MidEast.dll"), "MidEast");
37 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Rare.dll"), "Rare");
38 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Other.dll"), "Other");
40 List<int> list = new List<int> ();
41 for (int i = 1; i < 0x10000; i++) {
42 // Do this in a method to work around #5432
43 GetEncoding (i, list);
45 int [] reference = list.ToArray ();
47 EncodingInfo [] infos = Encoding.GetEncodings ();
48 int [] actual = new int [infos.Length];
50 for (int i = 0; i < infos.Length; i++)
51 actual [i] = infos [i].CodePage;
53 Assert.AreEqual (reference, actual);
57 public void GetEncodingForAllInfo ()
59 foreach (EncodingInfo i in Encoding.GetEncodings ())
60 Assert.IsNotNull (i.GetEncoding (), "codepage " + i);
63 void GetEncoding (int id, List<int> list) {
65 Encoding.GetEncoding (id);