5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) 2006 Novell, Inc.
12 using NUnit.Framework;
14 using System.Collections.Generic;
16 using System.Reflection;
19 namespace MonoTests.System.Text
22 public class EncodingInfoTest
25 // The purpose of this test is to make sure that
26 // new encodings added to I18N are also listed in the
27 // returned array from Encoding.GetEncodings() so that
28 // we can make sure to put additional encodings into
29 // Encoding.GetEncodings() code.
30 public void EncodingGetEncodingsReturnsAll ()
32 // Make sure that those I18N assemblies are loaded.
33 string basePath = Assembly.GetAssembly (typeof (int)).CodeBase;
34 basePath = basePath.Substring (0, basePath.LastIndexOf ('/'));
35 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.West.dll"), "West");
36 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.CJK.dll"), "CJK");
37 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.MidEast.dll"), "MidEast");
38 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Rare.dll"), "Rare");
39 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Other.dll"), "Other");
41 List<int> list = new List<int> ();
42 for (int i = 1; i < 0x10000; i++) {
44 Encoding.GetEncoding (i);
49 int [] reference = list.ToArray ();
51 EncodingInfo [] infos = Encoding.GetEncodings ();
52 int [] actual = new int [infos.Length];
54 for (int i = 0; i < infos.Length; i++)
55 actual [i] = infos [i].CodePage;
57 Assert.AreEqual (reference, actual);
61 public void GetEncodingForAllInfo ()
63 foreach (EncodingInfo i in Encoding.GetEncodings ())
64 Assert.IsNotNull (i.GetEncoding (), "codepage " + i);