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
26 [Category("NotWorking")]
28 // The purpose of this test is to make sure that
29 // new encodings added to I18N are also listed in the
30 // returned array from Encoding.GetEncodings() so that
31 // we can make sure to put additional encodings into
32 // Encoding.GetEncodings() code.
33 public void EncodingGetEncodingsReturnsAll ()
35 // Make sure that those I18N assemblies are loaded.
36 string basePath = Assembly.GetAssembly (typeof (int)).CodeBase;
37 basePath = basePath.Substring (0, basePath.LastIndexOf ('/'));
38 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.West.dll"), "West");
39 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.CJK.dll"), "CJK");
40 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.MidEast.dll"), "MidEast");
41 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Rare.dll"), "Rare");
42 Assert.IsNotNull (Assembly.LoadFrom (basePath + "/I18N.Other.dll"), "Other");
44 List<int> list = new List<int> ();
45 for (int i = 1; i < 0x10000; i++) {
47 Encoding.GetEncoding (i);
52 int [] reference = list.ToArray ();
54 EncodingInfo [] infos = Encoding.GetEncodings ();
55 int [] actual = new int [infos.Length];
57 for (int i = 0; i < infos.Length; i++)
58 actual [i] = infos [i].CodePage;
60 Assert.AreEqual (reference, actual);
64 public void GetEncodingForAllInfo ()
66 foreach (EncodingInfo i in Encoding.GetEncodings ())
67 Assert.IsNotNull (i.GetEncoding (), "codepage " + i);