[io-layer] add URLs for some ximian bug numbers in sockets.cs
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlReflectionImporterTests.cs
1 //
2 // System.Xml.Serialization.XmlReflectionImporterTests
3 //
4 // Author:
5 //   Erik LeBel (eriklebel@yahoo.ca)
6 //
7 // (C) 2003 Erik LeBel
8 // 
9 // FIXME test some of these with Xml Attributes attached to some members: 
10 // do the names get carried over to Element for XmlAttributeAttribute and XmlElementAttribute?
11 // 
12
13 using System;
14 using System.Collections;
15 using System.IO;
16 using System.Xml;
17 using System.Xml.Schema;
18 using System.Xml.Serialization;
19
20 using NUnit.Framework;
21 #if NET_2_0
22 using System.Collections.Generic;
23 #endif
24
25 using MonoTests.System.Xml.TestClasses;
26
27 namespace MonoTests.System.XmlSerialization
28 {
29         // debugging class
30         internal class Debug
31         {
32                 public static void Print(XmlTypeMapping tm)
33                 {
34                         Console.WriteLine("/XmlTypeMapping:");
35                         Console.WriteLine("ElementName: {0} ", tm.ElementName);
36                         Console.WriteLine("Namespace: {0} ", tm.Namespace);
37                         Console.WriteLine("TypeName: {0} ", tm.TypeName);
38                         Console.WriteLine("FullTypeName: {0} ", tm.TypeFullName);
39                 }
40
41                 public static void Print(XmlMemberMapping mm)
42                 {
43                         Console.WriteLine("/XmlMemberMapping:");
44                         Console.WriteLine("Any: {0} ", mm.Any);
45                         Console.WriteLine("ElementName: {0} ", mm.ElementName);
46                         Console.WriteLine("MemberName: {0} ", mm.MemberName);
47                         Console.WriteLine("Namespace: {0} ", mm.Namespace);
48                         Console.WriteLine("TypeFullName: {0} ", mm.TypeFullName);
49                         Console.WriteLine("TypeName: {0} ", mm.TypeName);
50                         Console.WriteLine("TypeNamespace: {0} ", mm.TypeNamespace);
51                 }
52         }
53
54         [TestFixture]
55         public class XmlReflectionImporterTests
56         {
57                 private const string SomeNamespace = "some:urn";
58                 private const string AnotherNamespace = "another:urn";
59                 private const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
60
61                 // these Map methods re-create the XmlReflectionImporter at every call.
62
63                 private XmlTypeMapping Map(Type t)
64                 {
65                         XmlReflectionImporter ri = new XmlReflectionImporter();
66                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
67                         //Debug.Print(tm);
68
69                         return tm;
70                 }
71
72                 private XmlTypeMapping Map(Type t, XmlRootAttribute root)
73                 {
74                         XmlReflectionImporter ri = new XmlReflectionImporter();
75                         XmlTypeMapping tm = ri.ImportTypeMapping(t, root);
76
77                         return tm;
78                 }
79
80                 private XmlTypeMapping Map(Type t, string ns)
81                 {
82                         XmlReflectionImporter ri = new XmlReflectionImporter(ns);
83                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
84                         //Debug.Print(tm);
85
86                         return tm;
87                 }
88
89                 private XmlTypeMapping Map (Type t, string ns, XmlRootAttribute root)
90                 {
91                         XmlReflectionImporter ri = new XmlReflectionImporter (ns);
92                         XmlTypeMapping tm = ri.ImportTypeMapping (t, root);
93
94                         return tm;
95                 }
96
97                 private XmlTypeMapping Map(Type t, XmlAttributeOverrides overrides)
98                 {
99                         XmlReflectionImporter ri = new XmlReflectionImporter(overrides);
100                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
101                         //Debug.Print(tm);
102
103                         return tm;
104                 }
105
106                 private XmlMembersMapping MembersMap(Type t, XmlAttributeOverrides overrides, 
107                         XmlReflectionMember [] members, bool inContainer)
108                 {
109                         XmlReflectionImporter ri = new XmlReflectionImporter(overrides);
110                         XmlMembersMapping mm = ri.ImportMembersMapping(null, null, members, inContainer);
111                         
112                         return mm;
113                 }
114                 
115                 [Test]
116                 public void TestIntTypeMapping()
117                 {
118                         XmlTypeMapping tm = Map(typeof(int));
119                         Assert.AreEqual ("int", tm.ElementName, "#1");
120                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
121                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
122                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
123                 }
124
125                 [Test]
126 #if NET_2_0
127                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
128 #endif
129                 public void TestIntTypeMapping_Array ()
130                 {
131                         XmlTypeMapping tm = Map(typeof(int[]));
132                         Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");
133                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
134 #if NET_2_0
135                         Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
136 #else
137                         Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");
138 #endif
139                         Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
140
141                         tm = Map (typeof (int[][]));
142                         Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");
143                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
144 #if NET_2_0
145                         Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");
146 #else
147                         Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");
148 #endif
149                         Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");
150
151                         tm = Map (typeof (int[][][]));
152                         Assert.AreEqual ("ArrayOfArrayOfArrayOfInt", tm.ElementName, "#C1");
153                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
154 #if NET_2_0
155                         Assert.AreEqual ("ArrayOfArrayOfArrayOfInt32", tm.TypeName, "#C3");
156 #else
157                         Assert.AreEqual ("Int32[][][]", tm.TypeName, "#C3");
158 #endif
159                         Assert.AreEqual ("System.Int32[][][]", tm.TypeFullName, "#C4");
160                 }
161
162                 [Test]
163                 public void TestStringTypeMapping()
164                 {
165                         XmlTypeMapping tm = Map(typeof(string));
166                         Assert.AreEqual ("string", tm.ElementName, "#1");
167                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
168                         Assert.AreEqual ("String", tm.TypeName, "#3");
169                         Assert.AreEqual ("System.String", tm.TypeFullName, "#4");
170                 }
171
172                 [Test]
173 #if NET_2_0
174                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
175 #endif
176                 public void TestStringTypeMapping_Array ()
177                 {
178                         XmlTypeMapping tm = Map (typeof (string[]));
179                         Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");
180                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
181 #if NET_2_0
182                         Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");
183 #else
184                         Assert.AreEqual ("String[]", tm.TypeName, "#A3");
185 #endif
186                         Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");
187
188                         tm = Map (typeof (string[][]));
189                         Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");
190                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
191 #if NET_2_0
192                         Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");
193 #else
194                         Assert.AreEqual ("String[][]", tm.TypeName, "#B3");
195 #endif
196                         Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");
197
198                         tm = Map (typeof (string[][][]));
199                         Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.ElementName, "#C1");
200                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
201 #if NET_2_0
202                         Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.TypeName, "#C3");
203 #else
204                         Assert.AreEqual ("String[][][]", tm.TypeName, "#C3");
205 #endif
206                         Assert.AreEqual ("System.String[][][]", tm.TypeFullName, "#C4");
207                 }
208
209                 [Test]
210                 public void TestObjectTypeMapping()
211                 {
212                         XmlTypeMapping tm = Map(typeof(object));
213                         Assert.AreEqual ("anyType", tm.ElementName, "#1");
214                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
215                         Assert.AreEqual ("Object", tm.TypeName, "#3");
216                         Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");
217                 }
218
219                 [Test]
220 #if NET_2_0
221                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
222 #endif
223                 public void TestObjectTypeMapping_Array ()
224                 {
225                         XmlTypeMapping tm = Map (typeof (object[]));
226                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");
227                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
228 #if NET_2_0
229                         Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");
230 #else
231                         Assert.AreEqual ("Object[]", tm.TypeName, "#A3");
232 #endif
233                         Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");
234
235                         tm = Map (typeof (object[][]));
236                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");
237                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
238 #if NET_2_0
239                         Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");
240 #else
241                         Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");
242 #endif
243                         Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");
244
245                         tm = Map (typeof (object[][][]));
246                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
247                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
248 #if NET_2_0
249                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObject", tm.TypeName, "#C3");
250 #else
251                         Assert.AreEqual ("Object[][][]", tm.TypeName, "#C3");
252 #endif
253                         Assert.AreEqual ("System.Object[][][]", tm.TypeFullName, "#C4");
254                 }
255
256                 [Test]
257                 public void TestByteTypeMapping()
258                 {
259                         XmlTypeMapping tm = Map(typeof(byte));
260                         Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");
261                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
262                         Assert.AreEqual ("Byte", tm.TypeName, "#3");
263                         Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");
264                 }
265
266                 [Test]
267 #if NET_2_0
268                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
269 #endif
270                 public void TestByteTypeMapping_Array ()
271                 {
272                         XmlTypeMapping tm = Map(typeof(byte[]));
273                         Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");
274                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
275                         Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");
276                         Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");
277
278                         tm = Map (typeof (byte[][]));
279                         Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");
280                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
281 #if NET_2_0
282                         Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");
283 #else
284                         Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");
285 #endif
286                         Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");
287
288                         tm = Map (typeof (byte[][][]));
289                         Assert.AreEqual ("ArrayOfArrayOfBase64Binary", tm.ElementName, "#C1");
290                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
291 #if NET_2_0
292                         Assert.AreEqual ("ArrayOfArrayOfArrayOfByte", tm.TypeName, "#C3");
293 #else
294                         Assert.AreEqual ("Byte[][][]", tm.TypeName, "#C3");
295 #endif
296                         Assert.AreEqual ("System.Byte[][][]", tm.TypeFullName, "#C4");
297                 }
298
299                 [Test]
300                 public void TestBoolTypeMapping()
301                 {
302                         XmlTypeMapping tm = Map(typeof(bool));
303                         Assert.AreEqual ("boolean", tm.ElementName, "#1");
304                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
305                         Assert.AreEqual ("Boolean", tm.TypeName, "#3");
306                         Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");
307                 }
308
309                 [Test]
310                 public void TestShortTypeMapping()
311                 {
312                         XmlTypeMapping tm = Map(typeof(short));
313                         Assert.AreEqual ("short", tm.ElementName, "#1");
314                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
315                         Assert.AreEqual ("Int16", tm.TypeName, "#3");
316                         Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");
317                 }
318
319                 [Test]
320                 public void TestUnsignedShortTypeMapping()
321                 {
322                         XmlTypeMapping tm = Map(typeof(ushort));
323                         Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");
324                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
325                         Assert.AreEqual ("UInt16", tm.TypeName, "#3");
326                         Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");
327                 }
328                 
329                 [Test]
330                 public void TestUIntTypeMapping()
331                 {
332                         XmlTypeMapping tm = Map(typeof(uint));
333                         Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");
334                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
335                         Assert.AreEqual ("UInt32", tm.TypeName, "#3");
336                         Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");
337                 }
338                 
339                 [Test]
340                 public void TestLongTypeMapping()
341                 {
342                         XmlTypeMapping tm = Map(typeof(long));
343                         Assert.AreEqual ("long", tm.ElementName, "#1");
344                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
345                         Assert.AreEqual ("Int64", tm.TypeName, "#3");
346                         Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");
347                 }
348                 
349                 [Test]
350                 public void TestULongTypeMapping()
351                 {
352                         XmlTypeMapping tm = Map(typeof(ulong));
353                         Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");
354                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
355                         Assert.AreEqual ("UInt64", tm.TypeName, "#3");
356                         Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");
357                 }
358                 
359                 [Test]
360                 public void TestFloatTypeMapping()
361                 {
362                         XmlTypeMapping tm = Map(typeof(float));
363                         Assert.AreEqual ("float", tm.ElementName, "#1");
364                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
365                         Assert.AreEqual ("Single", tm.TypeName, "#3");
366                         Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");
367                 }
368                 
369                 [Test]
370                 public void TestDoubleTypeMapping()
371                 {
372                         XmlTypeMapping tm = Map(typeof(double));
373                         Assert.AreEqual ("double", tm.ElementName, "#1");
374                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
375                         Assert.AreEqual ("Double", tm.TypeName, "#3");
376                         Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");
377                 }
378                 
379                 [Test]
380                 public void TestDateTimeTypeMapping()
381                 {
382                         XmlTypeMapping tm = Map(typeof(DateTime));
383                         Assert.AreEqual ("dateTime", tm.ElementName, "#1");
384                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
385                         Assert.AreEqual ("DateTime", tm.TypeName, "#3");
386                         Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");
387                 }
388
389                 [Test]
390 #if NET_2_0
391                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
392 #endif
393                 public void TestDateTimeTypeMapping_Array ()
394                 {
395                         XmlTypeMapping tm = Map (typeof (DateTime[]));
396                         Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");
397                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
398 #if NET_2_0
399                         Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");
400 #else
401                         Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");
402 #endif
403                         Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");
404
405                         tm = Map (typeof (DateTime[][]));
406                         Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");
407                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
408 #if NET_2_0
409                         Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");
410 #else
411                         Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");
412 #endif
413                         Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");
414
415                         tm = Map (typeof (DateTime[][][]));
416                         Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.ElementName, "#C1");
417                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
418 #if NET_2_0
419                         Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.TypeName, "#C3");
420 #else
421                         Assert.AreEqual ("DateTime[][][]", tm.TypeName, "#C3");
422 #endif
423                         Assert.AreEqual ("System.DateTime[][][]", tm.TypeFullName, "#C4");
424                 }
425
426                 [Test]
427                 public void TestGuidTypeMapping()
428                 {
429                         XmlTypeMapping tm = Map(typeof(Guid));
430                         Assert.AreEqual ("guid", tm.ElementName, "#1");
431                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
432                         Assert.AreEqual ("Guid", tm.TypeName, "#3");
433                         Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");
434                 }
435
436                 [Test]
437 #if NET_2_0
438                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
439 #endif
440                 public void TestGuidTypeMapping_Array ()
441                 {
442                         XmlTypeMapping tm = Map (typeof (Guid[]));
443                         Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");
444                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
445 #if NET_2_0
446                         Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");
447 #else
448                         Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");
449 #endif
450                         Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");
451
452                         tm = Map (typeof (Guid[][]));
453                         Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");
454                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
455 #if NET_2_0
456                         Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");
457 #else
458                         Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");
459 #endif
460                         Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");
461
462                         tm = Map (typeof (Guid[][][]));
463                         Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.ElementName, "#C1");
464                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
465 #if NET_2_0
466                         Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.TypeName, "#C3");
467 #else
468                         Assert.AreEqual ("Guid[][][]", tm.TypeName, "#C3");
469 #endif
470                         Assert.AreEqual ("System.Guid[][][]", tm.TypeFullName, "#C4");
471                 }
472
473                 [Test]
474                 public void TestDecimalTypeMapping()
475                 {
476                         XmlTypeMapping tm = Map(typeof(decimal));
477                         Assert.AreEqual ("decimal", tm.ElementName, "#1");
478                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
479                         Assert.AreEqual ("Decimal", tm.TypeName, "#3");
480                         Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");
481                 }
482                 
483                 [Test]
484                 public void TestXmlQualifiedNameTypeMapping()
485                 {
486                         XmlTypeMapping tm = Map(typeof(XmlQualifiedName));
487                         Assert.AreEqual ("QName", tm.ElementName, "#1");
488                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
489                         Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");
490                         Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");
491                 }
492                 
493                 [Test]
494                 public void TestSByteTypeMapping()
495                 {
496                         XmlTypeMapping tm = Map(typeof(sbyte));
497                         Assert.AreEqual ("byte", tm.ElementName, "#1");
498                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
499                         Assert.AreEqual ("SByte", tm.TypeName, "#3");
500                         Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");
501                 }
502                 
503
504                 [Test]
505                 public void TestCharTypeMapping()
506                 {
507                         XmlTypeMapping tm = Map(typeof(char));
508                         Assert.AreEqual ("char", tm.ElementName, "#1");
509                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
510                         Assert.AreEqual ("Char", tm.TypeName, "#3");
511                         Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");
512                 }
513
514                 [Test]
515 #if NET_2_0
516                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
517 #endif
518                 public void TestCharTypeMapping_Array ()
519                 {
520                         XmlTypeMapping tm = Map (typeof (char[]));
521                         Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");
522                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
523 #if NET_2_0
524                         Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");
525 #else
526                         Assert.AreEqual ("Char[]", tm.TypeName, "#A3");
527 #endif
528                         Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");
529
530                         tm = Map (typeof (char[][]));
531                         Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");
532                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
533 #if NET_2_0
534                         Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");
535 #else
536                         Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");
537 #endif
538                         Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");
539
540                         tm = Map (typeof (char[][][]));
541                         Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.ElementName, "#C1");
542                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
543 #if NET_2_0
544                         Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.TypeName, "#C3");
545 #else
546                         Assert.AreEqual ("Char[][][]", tm.TypeName, "#C3");
547 #endif
548                         Assert.AreEqual ("System.Char[][][]", tm.TypeFullName, "#C4");
549                 }
550
551                 [Test]
552                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
553                 public void TestXmlNodeTypeMapping ()
554                 {
555                         Type type = typeof (XmlNode);
556
557                         XmlTypeMapping tm = Map (type);
558                         Assert.AreEqual (string.Empty, tm.ElementName, "#A1");
559                         Assert.IsNull (tm.Namespace, "#A2");
560                         Assert.AreEqual ("XmlNode", tm.TypeName, "#A3");
561                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#A4");
562
563                         tm = Map (type, AnotherNamespace);
564                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
565                         Assert.IsNull (tm.Namespace, "#B2");
566                         Assert.AreEqual ("XmlNode", tm.TypeName, "#B3");
567                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#B4");
568
569                         XmlRootAttribute root = new XmlRootAttribute ("somename");
570                         root.Namespace = SomeNamespace;
571                         tm = Map (type, root);
572                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
573                         Assert.IsNull (tm.Namespace, "#C2");
574                         Assert.AreEqual ("XmlNode", tm.TypeName, "#C3");
575                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#C4");
576
577                         tm = Map (type, AnotherNamespace, root);
578                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
579                         Assert.IsNull (tm.Namespace, "#D2");
580                         Assert.AreEqual ("XmlNode", tm.TypeName, "#D3");
581                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#D4");
582
583                         root.Namespace = null;
584                         tm = Map (type, root);
585                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
586                         Assert.IsNull (tm.Namespace, "#E2");
587                         Assert.AreEqual ("XmlNode", tm.TypeName, "#E3");
588                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#E4");
589
590                         tm = Map (type, AnotherNamespace, root);
591                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
592                         Assert.IsNull (tm.Namespace, "#F2");
593                         Assert.AreEqual ("XmlNode", tm.TypeName, "#F3");
594                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#F4");
595                 }
596
597                 [Test]
598                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
599                 public void TestXmlElementTypeMapping ()
600                 {
601                         Type type = typeof (XmlElement);
602
603                         XmlTypeMapping tm = Map (type);
604                         Assert.AreEqual (string.Empty, tm.ElementName, "#1");
605                         Assert.IsNull (tm.Namespace, "#2");
606                         Assert.AreEqual ("XmlElement", tm.TypeName, "#3");
607                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#4");
608
609                         tm = Map (type, AnotherNamespace);
610                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
611                         Assert.IsNull (tm.Namespace, "#B2");
612                         Assert.AreEqual ("XmlElement", tm.TypeName, "#B3");
613                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#B4");
614
615                         XmlRootAttribute root = new XmlRootAttribute ("somename");
616                         root.Namespace = SomeNamespace;
617                         tm = Map (type, root);
618                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
619                         Assert.IsNull (tm.Namespace, "#C2");
620                         Assert.AreEqual ("XmlElement", tm.TypeName, "#C3");
621                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#C4");
622
623                         tm = Map (type, AnotherNamespace, root);
624                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
625                         Assert.IsNull (tm.Namespace, "#D2");
626                         Assert.AreEqual ("XmlElement", tm.TypeName, "#D3");
627                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#D4");
628
629                         root.Namespace = null;
630                         tm = Map (type, root);
631                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
632                         Assert.IsNull (tm.Namespace, "#E2");
633                         Assert.AreEqual ("XmlElement", tm.TypeName, "#E3");
634                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#E4");
635
636                         tm = Map (type, AnotherNamespace, root);
637                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
638                         Assert.IsNull (tm.Namespace, "#F2");
639                         Assert.AreEqual ("XmlElement", tm.TypeName, "#F3");
640                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#F4");
641                 }
642
643                 [Test]
644                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
645                 public void TestXmlNotationTypeMapping ()
646                 {
647                         Type type = typeof (XmlNotation);
648
649                         XmlTypeMapping tm = Map (type);
650                         Assert.AreEqual (string.Empty, tm.ElementName, "#1");
651                         Assert.IsNull (tm.Namespace, "#2");
652                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#3");
653                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#4");
654
655                         tm = Map (type, AnotherNamespace);
656                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
657                         Assert.IsNull (tm.Namespace, "#B2");
658                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#B3");
659                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#B4");
660
661                         XmlRootAttribute root = new XmlRootAttribute ("somename");
662                         root.Namespace = SomeNamespace;
663                         tm = Map (type, root);
664                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
665                         Assert.IsNull (tm.Namespace, "#C2");
666                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#C3");
667                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#C4");
668
669                         tm = Map (type, AnotherNamespace, root);
670                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
671                         Assert.IsNull (tm.Namespace, "#D2");
672                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#D3");
673                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#D4");
674
675                         root.Namespace = null;
676                         tm = Map (type, root);
677                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
678                         Assert.IsNull (tm.Namespace, "#E2");
679                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#E3");
680                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#E4");
681
682                         tm = Map (type, AnotherNamespace, root);
683                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
684                         Assert.IsNull (tm.Namespace, "#F2");
685                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#F3");
686                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#F4");
687                 }
688
689                 [Test]
690                 public void TestXmlSerializableTypeMapping ()
691                 {
692                         XmlTypeMapping tm = Map (typeof (Employee));
693                         Assert.AreEqual ("Employee", tm.ElementName, "#1");
694                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
695                         Assert.AreEqual ("Employee", tm.TypeName, "#3");
696                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee", tm.TypeFullName, "#4");
697                 }
698
699                 [Test]
700 #if NET_2_0
701                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
702 #endif
703                 public void TestXmlSerializableTypeMapping_Array ()
704                 {
705                         XmlTypeMapping tm = Map (typeof (Employee[]));
706                         Assert.AreEqual ("ArrayOfEmployee", tm.ElementName, "#A1");
707                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
708 #if NET_2_0
709                         Assert.AreEqual ("ArrayOfEmployee", tm.TypeName, "#A3");
710 #else
711                         Assert.AreEqual ("Employee[]", tm.TypeName, "#A3");
712 #endif
713                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[]", tm.TypeFullName, "#A4");
714
715                         tm = Map (typeof (Employee[][]));
716                         Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.ElementName, "#B1");
717                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
718 #if NET_2_0
719                         Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.TypeName, "#B3");
720 #else
721                         Assert.AreEqual ("Employee[][]", tm.TypeName, "#B3");
722 #endif
723                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][]", tm.TypeFullName, "#B4");
724
725                         tm = Map (typeof (Employee[][][]));
726                         Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.ElementName, "#C1");
727                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
728 #if NET_2_0
729                         Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.TypeName, "#C3");
730 #else
731                         Assert.AreEqual ("Employee[][][]", tm.TypeName, "#C3");
732 #endif
733                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][][]", tm.TypeFullName, "#C4");
734                 }
735
736                 [Test]
737                 public void TestClassTypeMapping_NestedStruct ()
738                 {
739                         XmlTypeMapping tm = Map (typeof (NestedStruct));
740                         Assert.AreEqual ("NestedStruct", tm.ElementName, "#1");
741                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
742                         Assert.AreEqual ("NestedStruct", tm.TypeName, "#3");
743                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.NestedStruct", tm.TypeFullName, "#4");
744                 }
745
746                 [Test]
747                 [ExpectedException (typeof (ArgumentNullException))]
748                 public void TestNullTypeMapping()
749                 {
750                         Map(null);
751                 }
752
753                 [Test]
754                 public void TestIntTypeMappingWithDefaultNamespaces()
755                 {
756                         XmlTypeMapping tm = Map(typeof(int), SomeNamespace);
757                         Assert.AreEqual ("int", tm.ElementName, "#1");
758                         Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
759                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
760                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
761                 }
762
763                 [Test]
764                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
765                 public void TestStructTypeMapping ()
766                 {
767                         XmlTypeMapping tm = Map (typeof (TimeSpan));
768                         Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");
769                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
770                         Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");
771                         Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");
772                 }
773
774                 [Test]
775                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
776                 public void TestStructTypeMapping_Array ()
777                 {
778                         XmlTypeMapping tm = Map (typeof (TimeSpan[]));
779                         Assert.AreEqual ("ArrayOfTimeSpan", tm.ElementName, "#A1");
780                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
781 #if NET_2_0
782                         Assert.AreEqual ("ArrayOfTimeSpan", tm.TypeName, "#A3");
783 #else
784                         Assert.AreEqual ("TimeSpan[]", tm.TypeName, "#A3");
785 #endif
786                         Assert.AreEqual ("System.TimeSpan[]", tm.TypeFullName, "#A4");
787
788                         tm = Map (typeof (TimeSpan[][]));
789                         Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.ElementName, "#B1");
790                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
791 #if NET_2_0
792                         Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.TypeName, "#B3");
793 #else
794                         Assert.AreEqual ("TimeSpan[][]", tm.TypeName, "#B3");
795 #endif
796                         Assert.AreEqual ("System.TimeSpan[][]", tm.TypeFullName, "#B4");
797
798                         tm = Map (typeof (TimeSpan[][][]));
799                         Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.ElementName, "#C1");
800                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
801 #if NET_2_0
802                         Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.TypeName, "#C3");
803 #else
804                         Assert.AreEqual ("TimeSpan[][][]", tm.TypeName, "#C3");
805 #endif
806                         Assert.AreEqual ("System.TimeSpan[][][]", tm.TypeFullName, "#C4");
807                 }
808
809                 [Test]
810                 public void TestEnumTypeMapping ()
811                 {
812                         XmlTypeMapping tm = Map (typeof (AttributeTargets));
813                         Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");
814                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
815                         Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");
816                         Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");
817                 }
818
819                 [Test]
820 #if NET_2_0
821                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
822 #endif
823                 public void TestEnumTypeMapping_Array ()
824                 {
825                         XmlTypeMapping tm = Map (typeof (AttributeTargets[]));
826                         Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");
827                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
828 #if NET_2_0
829                         Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");
830 #else
831                         Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");
832 #endif
833                         Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");
834
835                         tm = Map (typeof (AttributeTargets[][]));
836                         Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");
837                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
838 #if NET_2_0
839                         Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");
840 #else
841                         Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");
842 #endif
843                         Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");
844
845                         tm = Map (typeof (AttributeTargets[][][]));
846                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.ElementName, "#C1");
847                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
848 #if NET_2_0
849                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.TypeName, "#C3");
850 #else
851                         Assert.AreEqual ("AttributeTargets[][][]", tm.TypeName, "#C3");
852 #endif
853                         Assert.AreEqual ("System.AttributeTargets[][][]", tm.TypeFullName, "#C4");
854                 }
855
856                 [Test]
857                 public void TestClassTypeMapping()
858                 {
859                         XmlTypeMapping tm = Map (typeof (SimpleClass));
860                         Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");
861                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
862                         Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");
863                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");
864                 }
865
866                 [Test]
867 #if NET_2_0
868                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
869 #endif
870                 public void TestClassTypeMapping_Array ()
871                 {
872                         XmlTypeMapping tm = Map (typeof (SimpleClass[]));
873                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");
874                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
875 #if NET_2_0
876                         Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");
877 #else
878                         Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");
879 #endif
880                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");
881
882                         tm = Map (typeof (SimpleClass[][]));
883                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
884                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
885 #if NET_2_0
886                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");
887 #else
888                         Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");
889 #endif
890                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
891
892                         tm = Map (typeof (SimpleClass[][][]));
893                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
894                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
895 #if NET_2_0
896                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.TypeName, "#C3");
897 #else
898                         Assert.AreEqual ("SimpleClass[][][]", tm.TypeName, "#C3");
899 #endif
900                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][][]", tm.TypeFullName, "#C4");
901                 }
902
903                 [Test]
904                 [ExpectedException (typeof (NotSupportedException))]
905                 public void TypeMapping_IDictionary ()
906                 {
907                         // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer 
908                         // is not supported because it implements IDictionary.
909                         Map (typeof (DictionaryWithIndexer));
910                 }
911
912                 [Test]
913 #if NET_2_0
914                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
915 #endif
916                 public void TypeMapping_IEnumerable_SimpleClass ()
917                 {
918                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
919                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
920                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
921                         Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
922                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
923
924                         tm = Map (typeof (SimpleClassEnumerable[]));
925                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
926                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
927 #if NET_2_0
928                         Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
929 #else
930                         Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
931 #endif
932                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
933
934                         tm = Map (typeof (SimpleClassEnumerable[][]));
935                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
936                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
937 #if NET_2_0
938                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
939 #else
940                         Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
941 #endif
942                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
943
944                         tm = Map (typeof (SimpleClassEnumerable[][][]));
945                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
946                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
947 #if NET_2_0
948                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#C3");
949 #else
950                         Assert.AreEqual ("SimpleClassEnumerable[][][]", tm.TypeName, "#C3");
951 #endif
952                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][][]", tm.TypeFullName, "#C4");
953                 }
954
955                 [Test]
956 #if NET_2_0
957                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
958 #endif
959                 public void TypeMapping_IEnumerable_Object ()
960                 {
961                         XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
962                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
963                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
964                         Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
965                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
966
967                         tm = Map (typeof (ObjectEnumerable[]));
968                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
969                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
970 #if NET_2_0
971                         Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
972 #else
973                         Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
974 #endif
975                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
976
977                         tm = Map (typeof (ObjectEnumerable[][]));
978                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
979                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
980 #if NET_2_0
981                         Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
982 #else
983                         Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
984 #endif
985                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
986
987                         tm = Map (typeof (ObjectEnumerable[][][]));
988                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
989                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
990 #if NET_2_0
991                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectEnumerable", tm.TypeName, "#C3");
992 #else
993                         Assert.AreEqual ("ObjectEnumerable[][][]", tm.TypeName, "#C3");
994 #endif
995                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][][]", tm.TypeFullName, "#C4");
996                 }
997
998                 [Test]
999                 [ExpectedException (typeof (InvalidOperationException))]
1000                 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
1001                 {
1002                         Map (typeof (ObjectEnumerableNoMatchingAddMethod));
1003                 }
1004
1005                 [Test]
1006                 [ExpectedException (typeof (InvalidOperationException))]
1007                 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
1008                 {
1009                         Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
1010                 }
1011
1012                 [Test]
1013 #if NET_2_0
1014                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1015 #endif
1016                 public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
1017                 {
1018                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
1019                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1020                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1021                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
1022                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
1023
1024                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
1025                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1026                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1027 #if NET_2_0
1028                         Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
1029 #else
1030                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
1031 #endif
1032                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
1033
1034                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
1035                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1036                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1037 #if NET_2_0
1038                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
1039 #else
1040                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
1041 #endif
1042                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
1043
1044                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][][]));
1045                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1046                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1047 #if NET_2_0
1048                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#C3");
1049 #else
1050                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeName, "#C3");
1051 #endif
1052                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeFullName, "#C4");
1053                 }
1054
1055                 [Test]
1056 #if NET_2_0
1057                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1058 #endif
1059 #if ONLY_1_1
1060                 [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
1061 #endif
1062                 public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
1063                 {
1064                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
1065                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1066                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1067                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
1068                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
1069
1070                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
1071                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1072                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1073 #if NET_2_0
1074                         Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
1075 #else
1076                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
1077 #endif
1078                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
1079
1080                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
1081                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1082                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1083 #if NET_2_0
1084                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
1085 #else
1086                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
1087 #endif
1088                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
1089
1090                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][][]));
1091                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1092                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1093 #if NET_2_0
1094                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#C3");
1095 #else
1096                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeName, "#C3");
1097 #endif
1098                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeFullName, "#C4");
1099                 }
1100
1101                 [Test]
1102                 [ExpectedException (typeof (InvalidOperationException))]
1103                 public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
1104                 {
1105                         Map (typeof (ObjectCollectionNoMatchingAddMethod));
1106                 }
1107
1108                 [Test]
1109                 [ExpectedException (typeof (InvalidOperationException))]
1110                 public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
1111                 {
1112                         Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
1113                 }
1114
1115                 [Test]
1116                 [ExpectedException (typeof (InvalidOperationException))]
1117                 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
1118                 {
1119                         Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
1120                 }
1121
1122                 [Test]
1123                 [ExpectedException (typeof (InvalidOperationException))]
1124                 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
1125                 {
1126                         Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
1127                 }
1128
1129                 [Test]
1130 #if NET_2_0
1131                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1132 #endif
1133                 public void TypeMapping_ICollection_SimpleClass ()
1134                 {
1135                         XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
1136                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
1137                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1138                         Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
1139                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
1140
1141                         tm = Map (typeof (SimpleClassCollection[]));
1142                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
1143                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1144 #if NET_2_0
1145                         Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
1146 #else
1147                         Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
1148 #endif
1149                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
1150
1151                         tm = Map (typeof (SimpleClassCollection[][]));
1152                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
1153                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1154 #if NET_2_0
1155                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
1156 #else
1157                         Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
1158 #endif
1159                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
1160
1161                         tm = Map (typeof (SimpleClassCollection[][][]));
1162                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
1163                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1164 #if NET_2_0
1165                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#C3");
1166 #else
1167                         Assert.AreEqual ("SimpleClassCollection[][][]", tm.TypeName, "#C3");
1168 #endif
1169                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][][]", tm.TypeFullName, "#C4");
1170                 }
1171
1172                 [Test]
1173 #if NET_2_0
1174                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1175 #endif
1176                 public void TypeMapping_ICollection_Object ()
1177                 {
1178                         XmlTypeMapping tm = Map (typeof (ObjectCollection));
1179                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1180                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1181                         Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
1182                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
1183
1184                         tm = Map (typeof (ObjectCollection[]));
1185                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1186                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1187 #if NET_2_0
1188                         Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
1189 #else
1190                         Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
1191 #endif
1192                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
1193
1194                         tm = Map (typeof (ObjectCollection[][]));
1195                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1196                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1197 #if NET_2_0
1198                         Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
1199 #else
1200                         Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
1201 #endif
1202                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
1203
1204                         tm = Map (typeof (ObjectCollection[][][]));
1205                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1206                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1207 #if NET_2_0
1208                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectCollection", tm.TypeName, "#C3");
1209 #else
1210                         Assert.AreEqual ("ObjectCollection[][][]", tm.TypeName, "#C3");
1211 #endif
1212                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][][]", tm.TypeFullName, "#C4");
1213                 }
1214
1215                 [Test]
1216                 [ExpectedException (typeof (InvalidOperationException))]
1217                 public void TypeMapping_ICollection_Object_NoIntIndexer ()
1218                 {
1219                         Map (typeof (ObjectCollectionNoIntIndexer));
1220                 }
1221
1222                 [Test]
1223                 [ExpectedException (typeof (InvalidOperationException))]
1224                 public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
1225                 {
1226                         Map (typeof (ObjectCollectionNoIntIndexer[]));
1227                 }
1228
1229                 [Test]
1230                 [ExpectedException (typeof (InvalidOperationException))]
1231                 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
1232                 {
1233                         Map (typeof (SimpleClassCollectionNoIntIndexer));
1234                 }
1235
1236                 [Test]
1237                 [ExpectedException (typeof (InvalidOperationException))]
1238                 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
1239                 {
1240                         Map (typeof (SimpleClassCollectionNoIntIndexer[]));
1241                 }
1242
1243                 [Test]
1244                 public void TypeMapping_InvalidDefault ()
1245                 {
1246                         XmlAttributes attrs = new XmlAttributes (typeof (Field).GetMember ("Modifiers") [0]);
1247                         attrs.XmlDefaultValue = 2; // not a defined enum value
1248                         XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
1249                         overrides.Add (typeof (Field), "Modifiers", attrs);
1250
1251                         try {
1252                                 Map (typeof (Field), overrides);
1253                                 Assert.Fail ("#A1");
1254                         } catch (InvalidOperationException ex) {
1255                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1256                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1257                                 Assert.IsNotNull (ex.Message, "#A3");
1258                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#A4");
1259                                 Assert.IsNotNull (ex.InnerException, "#A5");
1260
1261                                 // There was an error reflecting field 'Modifiers'
1262                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#A6");
1263                                 Assert.IsNotNull (ex.InnerException.Message, "#A7");
1264                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#A8");
1265                                 Assert.IsNotNull (ex.InnerException.InnerException, "#A9");
1266
1267                                 // Value '2' cannot be converted to System.Int32
1268                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.InnerException.GetType (), "#A10");
1269                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#A11");
1270                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'2'") != -1, "#A12");
1271                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (int).FullName) != -1, "#A13");
1272                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#A14");
1273                         }
1274
1275                         attrs.XmlDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
1276
1277                         try {
1278                                 Map (typeof (Field), overrides);
1279                                 Assert.Fail ("#B1");
1280                         } catch (InvalidOperationException ex) {
1281                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1282                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
1283                                 Assert.IsNotNull (ex.Message, "#B3");
1284                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#B4");
1285                                 Assert.IsNotNull (ex.InnerException, "#B5");
1286
1287                                 // There was an error reflecting field 'Modifiers'
1288                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#B6");
1289                                 Assert.IsNotNull (ex.InnerException.Message, "#B7");
1290                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#B8");
1291                                 Assert.IsNotNull (ex.InnerException.InnerException, "#B9");
1292
1293                                 // Enum underlying type and the object must be same type or object.
1294                                 // Type passed in was 'System.String'; the enum underlying type was
1295                                 // 'System.Int32'.
1296                                 Assert.AreEqual (typeof (ArgumentException), ex.InnerException.InnerException.GetType (), "#B10");
1297                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#B11");
1298                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (string).FullName) != -1, "#B12");
1299                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (int).FullName) != -1, "#B13");
1300                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#B14");
1301                         }
1302
1303                         attrs.XmlDefaultValue = EnumDefaultValueNF.e2; // other enum type
1304
1305                         try {
1306                                 Map (typeof (Field), overrides);
1307                                 Assert.Fail ("#C1");
1308                         } catch (InvalidOperationException ex) {
1309                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1310                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
1311                                 Assert.IsNotNull (ex.Message, "#C3");
1312                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#C4");
1313                                 Assert.IsNotNull (ex.InnerException, "#C5");
1314
1315                                 // There was an error reflecting field 'Modifiers'
1316                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#C6");
1317                                 Assert.IsNotNull (ex.InnerException.Message, "#C7");
1318                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#C8");
1319                                 Assert.IsNotNull (ex.InnerException.InnerException, "#C9");
1320
1321                                 // Object must be the same type as the enum. The type passed in
1322                                 // was MonoTests.System.Xml.TestClasses.EnumDefaultValueNF; the
1323                                 // enum type was MonoTests.System.Xml.TestClasses.MapModifiers
1324                                 Assert.AreEqual (typeof (ArgumentException), ex.InnerException.InnerException.GetType (), "#C10");
1325                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#C11");
1326                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C12");
1327                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C13");
1328                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#C14");
1329                         }
1330
1331                         attrs.XmlDefaultValue = (MapModifiers) 20; // non-existing enum value
1332
1333                         try {
1334                                 Map (typeof (Field), overrides);
1335                                 Assert.Fail ("#D1");
1336                         } catch (InvalidOperationException ex) {
1337                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1338                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1339                                 Assert.IsNotNull (ex.Message, "#D3");
1340                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#D4");
1341                                 Assert.IsNotNull (ex.InnerException, "#D5");
1342
1343                                 // There was an error reflecting field 'Modifiers'
1344                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#D6");
1345                                 Assert.IsNotNull (ex.InnerException.Message, "#D7");
1346                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#D8");
1347                                 Assert.IsNotNull (ex.InnerException.InnerException, "#D9");
1348
1349                                 // Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1350                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.InnerException.GetType (), "#D10");
1351                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#D11");
1352                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'20'") != -1, "#D12");
1353                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D13");
1354                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#D14");
1355                         }
1356                 }
1357
1358                 [Test]
1359                 [ExpectedException (typeof (ArgumentNullException))]
1360                 public void TypeMapping_Null ()
1361                 {
1362                         Map ((Type) null);
1363                 }
1364
1365                 [Test]
1366                 [ExpectedException (typeof (NotSupportedException))]
1367                 public void TypeMapping_Void ()
1368                 {
1369                         Map (typeof (void));
1370                 }
1371
1372                 [Test]
1373                 public void TypeMapping_WrongChoices ()
1374                 {
1375                         try {
1376                                 Map (typeof (WrongChoices));
1377                                 Assert.Fail ("#1");
1378                         } catch (InvalidOperationException ex) {
1379                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.WrongChoices'
1380                                 Assert.IsNotNull (ex.Message, "#2");
1381                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (WrongChoices).FullName + "'") != -1, "#3");
1382                                 Assert.IsNotNull (ex.InnerException, "#4");
1383
1384                                 // There was an error reflecting field 'MyChoice'
1385                                 Assert.IsNotNull (ex.InnerException.Message, "#5");
1386                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'MyChoice'") != -1, "#6");
1387                                 Assert.IsNotNull (ex.InnerException.InnerException, "#7");
1388
1389                                 // Type MonoTests.System.Xml.TestClasses.ItemChoiceType is missing 
1390                                 // enumeration value 'StrangeOne' for element 'StrangeOne' from
1391                                 // namespace ''.
1392                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#8");
1393                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (ItemChoiceType).FullName) != -1, "#9");
1394                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'StrangeOne'") != -1, "#10");
1395                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("''") != -1, "#11");
1396                         }
1397                 }
1398
1399                 [Test] // bug #77591
1400                 public void TypeMapping_XmlText_PrimitiveTypes ()
1401                 {
1402                         XmlAttributeOverrides overrides = null;
1403                         XmlAttributes attrs = null;
1404
1405                         overrides = new XmlAttributeOverrides ();
1406                         attrs = new  XmlAttributes ();
1407                         attrs.XmlText = new XmlTextAttribute (typeof (int));
1408                         overrides.Add (typeof (Field), "Modifiers", attrs);
1409
1410                         try {
1411                                 Map (typeof (Field), overrides);
1412                                 Assert.Fail ("#A1");
1413                         } catch (InvalidOperationException ex) {
1414                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.Field'
1415                                 Assert.IsNotNull (ex.Message, "#A2");
1416                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (Field).FullName + "'") != -1, "#A3");
1417                                 Assert.IsNotNull (ex.InnerException, "#A4");
1418
1419                                 // There was an error reflecting field 'Modifiers'
1420                                 Assert.IsNotNull (ex.InnerException.Message, "#A5");
1421                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#A6");
1422                                 Assert.IsNotNull (ex.InnerException.InnerException, "#A7");
1423
1424                                 // The type for XmlText may not be specified for primitive types
1425                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#A8");
1426                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("XmlText") != -1, "#A9");
1427                         }
1428
1429                         overrides = new XmlAttributeOverrides ();
1430                         attrs = new XmlAttributes ();
1431                         attrs.XmlText = new XmlTextAttribute (typeof (int));
1432                         overrides.Add (typeof (Field), "Street", attrs);
1433
1434                         try {
1435                                 Map (typeof (Field), overrides);
1436                                 Assert.Fail ("#B1");
1437                         } catch (InvalidOperationException ex) {
1438                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.Field'
1439                                 Assert.IsNotNull (ex.Message, "#B2");
1440                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (Field).FullName + "'") != -1, "#B3");
1441                                 Assert.IsNotNull (ex.InnerException, "#B4");
1442
1443                                 // There was an error reflecting field 'Street'
1444                                 Assert.IsNotNull (ex.InnerException.Message, "#B5");
1445                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Street'") != -1, "#B6");
1446                                 Assert.IsNotNull (ex.InnerException.InnerException, "#B7");
1447
1448                                 // The type for XmlText may not be specified for primitive types
1449                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#B8");
1450                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("XmlText") != -1, "#B9");
1451                         }
1452
1453                         overrides = new XmlAttributeOverrides ();
1454                         attrs = new XmlAttributes ();
1455                         attrs.XmlText = new XmlTextAttribute (typeof (MapModifiers));
1456                         overrides.Add (typeof (Field), "Modifiers", attrs);
1457                         Map (typeof (Field), overrides);
1458
1459                         overrides = new XmlAttributeOverrides ();
1460                         attrs = new XmlAttributes ();
1461                         attrs.XmlText = new XmlTextAttribute (typeof (string));
1462                         overrides.Add (typeof (Field), "Street", attrs);
1463                         Map (typeof (Field), overrides);
1464                 }
1465
1466                 [Test]
1467                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1468                 public void TestImportMembersMapping()
1469                 {
1470                         Type type = typeof(SimpleClass);
1471                         XmlAttributes attrs = new  XmlAttributes();
1472                         XmlAttributeOverrides overrides = new XmlAttributeOverrides();
1473                         overrides.Add(typeof(SimpleClass), attrs);
1474
1475                         XmlReflectionMember[] members = new XmlReflectionMember[0];
1476                         XmlMembersMapping mm;
1477                         try
1478                         {
1479                                 mm = MembersMap(type, overrides, members, true);
1480                                 Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
1481                         }
1482                         catch (Exception)
1483                         {
1484                         }
1485                         
1486                         XmlReflectionMember rm = new XmlReflectionMember();
1487                         rm.IsReturnValue = false;
1488                         rm.MemberName = "something";
1489                         rm.MemberType = typeof(string);
1490                         members = new XmlReflectionMember[1];
1491                         members[0] = rm;
1492
1493                         mm = MembersMap(type, overrides, members, false);
1494
1495                         Equals(mm.Count, 1);
1496
1497                         XmlMemberMapping smm = mm[0];
1498                         Assert.IsFalse (smm.Any, "#1");
1499                         Assert.AreEqual ("something", smm.ElementName, "#2");
1500                         Assert.AreEqual ("something", smm.MemberName, "#3");
1501                         Assert.IsNull (smm.Namespace, "#4");
1502                         Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
1503                         Assert.AreEqual ("string", smm.TypeName, "#6");
1504 #if NET_2_0
1505                         Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");
1506 #else
1507                         Assert.IsNull (smm.TypeNamespace, "#7");
1508 #endif
1509
1510                         rm = new XmlReflectionMember();
1511                         rm.IsReturnValue = false;
1512                         rm.MemberName = "nothing";
1513                         rm.MemberType = typeof(string);
1514                         members = new XmlReflectionMember[1];
1515                         members[0] = rm;
1516
1517                         mm = MembersMap(type, overrides, members, false);
1518                         Assert.AreEqual (1, mm.Count, "#8");
1519                 }
1520
1521                 [Test]
1522                 public void TestIntTypeMappingWithXmlRootAttribute()
1523                 {
1524                         const string TheNamespace = "another:urn";
1525                         XmlRootAttribute root = new XmlRootAttribute("price");
1526                         root.Namespace = TheNamespace;
1527                         
1528                         XmlTypeMapping tm = Map(typeof(int), root);
1529                         Assert.AreEqual ("price", tm.ElementName, "#1");
1530                         Assert.AreEqual (TheNamespace, tm.Namespace, "#2");
1531                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
1532                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
1533                 }
1534                 
1535                 [Test]
1536                 [ExpectedException (typeof (InvalidOperationException))]
1537                 public void TestSerializeWrongChoice ()
1538                 {
1539                         new XmlSerializer (typeof(WrongChoices));
1540                 }
1541
1542                 [Test]
1543                 public void XmlArrayOnByteArray ()
1544                 {
1545                         new XmlSerializer (typeof (XmlArrayOnByteArrayType));
1546                 }
1547
1548 #if NET_2_0
1549
1550                 [Test]
1551                 public void ImportNullableInt ()
1552                 {
1553                         XmlReflectionImporter imp = new XmlReflectionImporter ();
1554                         XmlTypeMapping map = imp.ImportTypeMapping (typeof (int?));
1555                         XmlSchemas schemas = new XmlSchemas ();
1556                         XmlSchemaExporter exp = new XmlSchemaExporter (schemas);
1557                         exp.ExportTypeMapping (map);
1558                         XmlSchema schema = schemas [0];
1559                         XmlSchemaElement el = schema.Items [0] as XmlSchemaElement;
1560                         Assert.AreEqual ("int", el.Name, "#1");
1561                         Assert.AreEqual (new XmlQualifiedName ("int", XmlSchema.Namespace), el.SchemaTypeName, "#2");
1562                         Assert.AreEqual (true, el.IsNillable, "#3");
1563                 }
1564
1565                 [Test]
1566                 public void ImportNullableContainer ()
1567                 {
1568                         new XmlSerializer (typeof (NullableContainer));
1569                 }
1570
1571                 [Test]
1572                 public void ImportNullableContainer2 ()
1573                 {
1574                         XmlReflectionImporter imp = new XmlReflectionImporter ();
1575                         XmlTypeMapping map = imp.ImportTypeMapping (typeof (NullableContainer2));
1576                         XmlSchemas schemas = new XmlSchemas ();
1577                         XmlSchemaExporter exp = new XmlSchemaExporter (schemas);
1578                         exp.ExportTypeMapping (map);
1579
1580                         XmlSchema schema = schemas [0];
1581                         XmlSchemaComplexType el = schema.Items [1] as XmlSchemaComplexType;
1582
1583                         XmlSchemaSequence s = el.Particle as XmlSchemaSequence;
1584                         XmlSchemaElement el2 = s.Items [0] as XmlSchemaElement;
1585                         Assert.IsTrue (el2.IsNillable);
1586                 }
1587
1588                 [Test]
1589                 [ExpectedException (typeof (InvalidOperationException))]
1590                 public void ImportGenericTypeDefinition ()
1591                 {
1592                         new XmlSerializer (typeof (List<int>).GetGenericTypeDefinition ());
1593                 }
1594
1595                 [Test]
1596                 [ExpectedException (typeof (InvalidOperationException))]
1597                 public void XmlSchemaProviderMissingMethod ()
1598                 {
1599                         new XmlSerializer (typeof (XmlSchemaProviderMissingMethodType));
1600                 }
1601
1602                 [Test]
1603                 [ExpectedException (typeof (InvalidOperationException))]
1604                 public void XmlSchemaProviderMethodNonStatic ()
1605                 {
1606                         new XmlSerializer (typeof (XmlSchemaProviderNonStaticType));
1607                 }
1608
1609                 [Test]
1610                 [ExpectedException (typeof (InvalidOperationException))]
1611                 public void XmlSchemaProviderMethodIncorrectReturn ()
1612                 {
1613                         new XmlSerializer (typeof (XmlSchemaProviderIncorrectReturnType));
1614                 }
1615
1616                 [Test]
1617                 public void XmlSchemaProviderAndDefaultNamespace ()
1618                 {
1619                         XmlTypeMapping tm = new XmlReflectionImporter ("urn:bar").ImportTypeMapping (typeof (XmlSchemaProviderAndDefaultNamespaceType));
1620                         Assert.AreEqual ("foo", tm.ElementName, "#1");
1621                         Assert.AreEqual ("foo", tm.XsdTypeName, "#2");
1622                         Assert.AreEqual ("urn:bar", tm.Namespace, "#3");
1623                         Assert.AreEqual ("urn:foo", tm.XsdTypeNamespace);
1624                 }
1625
1626                 [Test]
1627                 public void ImportGenericICollectionWrapped ()
1628                 {
1629                         new XmlSerializer (typeof (MyCollection));
1630                 }
1631
1632                 [Test]
1633                 public void Bug704813Type ()
1634                 {
1635                         var xs = new XmlSerializer (typeof (Bug704813Type));
1636                         xs.Serialize (TextWriter.Null, new Bug704813Type ());
1637                 }
1638
1639                 [Test]
1640                 public void Bug708178Type()
1641                 {
1642                         XmlSerializer xmlSerializer = new XmlSerializer (typeof(Bug708178Type));
1643                         Bug708178Type bugType = new Bug708178Type ();
1644                         bugType.Foo.Add ("test");
1645                         Assert.AreEqual (1, bugType.Foo.Count);
1646                  
1647                         //xml Serialize
1648                         TextWriter WriteFileStream = new StreamWriter (@"Bug708178Type.xml", false);
1649                         xmlSerializer.Serialize (WriteFileStream, bugType);
1650                         WriteFileStream.Close ();
1651                  
1652                         //xml Deserialize
1653                         FileStream ReadFileStream = new FileStream (@"Bug708178Type.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
1654                         Bug708178Type bugTypeReload = (Bug708178Type)xmlSerializer.Deserialize (ReadFileStream);
1655                  
1656                         //should have deserialized the relationship
1657                         Assert.AreEqual(1, bugTypeReload.Foo.Count);
1658                }
1659 #endif
1660
1661                 public class Employee : IXmlSerializable
1662                 {
1663                         private string _firstName;
1664                         private string _lastName;
1665                         private string _address;
1666
1667                         public XmlSchema GetSchema ()
1668                         {
1669                                 return null;
1670                         }
1671
1672                         public void WriteXml (XmlWriter writer)
1673                         {
1674                                 writer.WriteStartElement ("employee", "urn:devx-com");
1675                                 writer.WriteAttributeString ("firstName", _firstName);
1676                                 writer.WriteAttributeString ("lastName", _lastName);
1677                                 writer.WriteAttributeString ("address", _address);
1678                                 writer.WriteEndElement ();
1679                         }
1680
1681                         public void ReadXml (XmlReader reader)
1682                         {
1683                                 XmlNodeType type = reader.MoveToContent ();
1684                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
1685                                         _firstName = reader["firstName"];
1686                                         _lastName = reader["lastName"];
1687                                         _address = reader["address"];
1688                                 }
1689                         }
1690                 }
1691
1692                 public class NestedStruct
1693                 {
1694                         public TimeSpan Period = TimeSpan.MaxValue;
1695                 }
1696
1697                 public class ObjectEnumerable : IEnumerable
1698                 {
1699                         public void Add (int value)
1700                         {
1701                         }
1702
1703                         public void Add (object value)
1704                         {
1705                         }
1706
1707                         public IEnumerator GetEnumerator ()
1708                         {
1709                                 return new ArrayList ().GetEnumerator ();
1710                         }
1711                 }
1712
1713                 public class SimpleClassEnumerable : IEnumerable
1714                 {
1715                         public void Add (int value)
1716                         {
1717                         }
1718
1719                         public void Add (object value)
1720                         {
1721                         }
1722
1723                         IEnumerator IEnumerable.GetEnumerator ()
1724                         {
1725                                 return GetEnumerator ();
1726                         }
1727
1728                         public SimpleClassEnumerator GetEnumerator ()
1729                         {
1730                                 return new SimpleClassEnumerator (new ArrayList ());
1731                         }
1732                 }
1733
1734                 public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
1735                 {
1736                         public void Add (object value)
1737                         {
1738                         }
1739
1740                         IEnumerator IEnumerable.GetEnumerator ()
1741                         {
1742                                 return new ArrayList ().GetEnumerator ();
1743                         }
1744                 }
1745
1746                 public class SimpleClassEnumerablePrivateCurrent : IEnumerable
1747                 {
1748                         public void Add (object value)
1749                         {
1750                         }
1751
1752                         IEnumerator IEnumerable.GetEnumerator ()
1753                         {
1754                                 return GetEnumerator ();
1755                         }
1756
1757                         public NoCurrentEnumerator GetEnumerator ()
1758                         {
1759                                 return new NoCurrentEnumerator (new ArrayList ());
1760                         }
1761                 }
1762
1763                 // GetEnumerator().Current returns object, but there's no corresponding
1764                 // Add (System.Object) method
1765                 public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
1766                 {
1767                         public void Add (int value)
1768                         {
1769                         }
1770
1771                         public IEnumerator GetEnumerator ()
1772                         {
1773                                 return new ArrayList ().GetEnumerator ();
1774                         }
1775                 }
1776
1777                 // GetEnumerator().Current returns SimpleClass, but there's no 
1778                 // corresponding Add (SimpleClass) method
1779                 public class SimpleClassCollectionNoMatchingAddMethod : ICollection
1780                 {
1781                         public SimpleClass this[int index]
1782                         {
1783                                 get
1784                                 {
1785                                         return (SimpleClass) _list[index];
1786                                 }
1787                         }
1788
1789                         public int Count
1790                         {
1791                                 get { return _list.Count; }
1792                         }
1793
1794                         public bool IsSynchronized
1795                         {
1796                                 get { return _list.IsSynchronized; }
1797                         }
1798
1799                         public object SyncRoot
1800                         {
1801                                 get { return _list.SyncRoot; }
1802                         }
1803
1804                         public void CopyTo (Array array, int index)
1805                         {
1806                                 _list.CopyTo (array, index);
1807                         }
1808
1809                         IEnumerator IEnumerable.GetEnumerator ()
1810                         {
1811                                 return GetEnumerator ();
1812                         }
1813
1814                         public SimpleClassEnumerator GetEnumerator ()
1815                         {
1816                                 return new SimpleClassEnumerator (_list);
1817                         }
1818
1819                         private ArrayList _list = new ArrayList ();
1820                 }
1821
1822                 // GetEnumerator().Current returns object, but there's no corresponding
1823                 // Add (System.Object) method
1824                 public class ObjectCollectionNoMatchingAddMethod : ICollection
1825                 {
1826                         public object this[int index]
1827                         {
1828                                 get
1829                                 {
1830                                         return _list[index];
1831                                 }
1832                         }
1833
1834                         public int Count
1835                         {
1836                                 get { return _list.Count; }
1837                         }
1838
1839                         public bool IsSynchronized
1840                         {
1841                                 get { return _list.IsSynchronized; }
1842                         }
1843
1844                         public object SyncRoot
1845                         {
1846                                 get { return _list.SyncRoot; }
1847                         }
1848
1849                         public void CopyTo (Array array, int index)
1850                         {
1851                                 _list.CopyTo (array, index);
1852                         }
1853
1854                         IEnumerator IEnumerable.GetEnumerator ()
1855                         {
1856                                 return GetEnumerator ();
1857                         }
1858
1859                         public IEnumerator GetEnumerator ()
1860                         {
1861                                 return _list.GetEnumerator ();
1862                         }
1863
1864                         private ArrayList _list = new ArrayList ();
1865                 }
1866
1867                 // Does not have int indexer.
1868                 public class SimpleClassCollectionNoIntIndexer : ICollection
1869                 {
1870                         public SimpleClass this[string name]
1871                         {
1872                                 get
1873                                 {
1874                                         return new SimpleClass ();
1875                                 }
1876                         }
1877
1878                         public int Count
1879                         {
1880                                 get { return _list.Count; }
1881                         }
1882
1883                         public bool IsSynchronized
1884                         {
1885                                 get { return _list.IsSynchronized; }
1886                         }
1887
1888                         public object SyncRoot
1889                         {
1890                                 get { return _list.SyncRoot; }
1891                         }
1892
1893                         public void CopyTo (Array array, int index)
1894                         {
1895                                 _list.CopyTo (array, index);
1896                         }
1897
1898                         IEnumerator IEnumerable.GetEnumerator ()
1899                         {
1900                                 return GetEnumerator ();
1901                         }
1902
1903                         public SimpleClassEnumerator GetEnumerator ()
1904                         {
1905                                 return new SimpleClassEnumerator (_list);
1906                         }
1907
1908                         public void Add (SimpleClass value)
1909                         {
1910                                 _list.Add (value);
1911                         }
1912
1913                         private ArrayList _list = new ArrayList ();
1914                 }
1915
1916                 // Does not have int indexer.
1917                 public class ObjectCollectionNoIntIndexer : ICollection
1918                 {
1919                         public object this[string name]
1920                         {
1921                                 get
1922                                 {
1923                                         return new SimpleClass ();
1924                                 }
1925                         }
1926
1927                         public int Count
1928                         {
1929                                 get { return _list.Count; }
1930                         }
1931
1932                         public bool IsSynchronized
1933                         {
1934                                 get { return _list.IsSynchronized; }
1935                         }
1936
1937                         public object SyncRoot
1938                         {
1939                                 get { return _list.SyncRoot; }
1940                         }
1941
1942                         public void CopyTo (Array array, int index)
1943                         {
1944                                 _list.CopyTo (array, index);
1945                         }
1946
1947                         public IEnumerator GetEnumerator ()
1948                         {
1949                                 return _list.GetEnumerator ();
1950                         }
1951
1952                         public void Add (object value)
1953                         {
1954                                 _list.Add (value);
1955                         }
1956
1957                         private ArrayList _list = new ArrayList ();
1958                 }
1959
1960                 public class SimpleClassCollection : ICollection
1961                 {
1962                         public SimpleClass this[int index]
1963                         {
1964                                 get
1965                                 {
1966                                         return (SimpleClass) _list[index];
1967                                 }
1968                         }
1969
1970                         public int Count
1971                         {
1972                                 get { return _list.Count; }
1973                         }
1974
1975                         public bool IsSynchronized
1976                         {
1977                                 get { return _list.IsSynchronized; }
1978                         }
1979
1980                         public object SyncRoot
1981                         {
1982                                 get { return _list.SyncRoot; }
1983                         }
1984
1985                         public void CopyTo (Array array, int index)
1986                         {
1987                                 _list.CopyTo (array, index);
1988                         }
1989
1990                         IEnumerator IEnumerable.GetEnumerator ()
1991                         {
1992                                 return GetEnumerator ();
1993                         }
1994
1995                         public SimpleClassEnumerator GetEnumerator ()
1996                         {
1997                                 return new SimpleClassEnumerator (_list);
1998                         }
1999
2000                         public void Add (SimpleClass value)
2001                         {
2002                                 _list.Add (value);
2003                         }
2004
2005                         private ArrayList _list = new ArrayList ();
2006                 }
2007
2008                 public class ObjectCollection : ICollection
2009                 {
2010                         public object this[int name]
2011                         {
2012                                 get
2013                                 {
2014                                         return new SimpleClass ();
2015                                 }
2016                         }
2017
2018                         public int Count
2019                         {
2020                                 get { return _list.Count; }
2021                         }
2022
2023                         public bool IsSynchronized
2024                         {
2025                                 get { return _list.IsSynchronized; }
2026                         }
2027
2028                         public object SyncRoot
2029                         {
2030                                 get { return _list.SyncRoot; }
2031                         }
2032
2033                         public void CopyTo (Array array, int index)
2034                         {
2035                                 _list.CopyTo (array, index);
2036                         }
2037
2038                         public IEnumerator GetEnumerator ()
2039                         {
2040                                 return _list.GetEnumerator ();
2041                         }
2042
2043                         public void Add (object value)
2044                         {
2045                                 _list.Add (value);
2046                         }
2047
2048                         private ArrayList _list = new ArrayList ();
2049                 }
2050
2051                 public class SimpleClassEnumerator : IEnumerator
2052                 {
2053                         internal SimpleClassEnumerator (ArrayList arguments)
2054                         {
2055                                 IEnumerable temp = (IEnumerable) (arguments);
2056                                 _baseEnumerator = temp.GetEnumerator ();
2057                         }
2058                         public SimpleClass Current
2059                         {
2060                                 get { return (SimpleClass) _baseEnumerator.Current; }
2061                         }
2062
2063                         object IEnumerator.Current
2064                         {
2065                                 get { return _baseEnumerator.Current; }
2066                         }
2067
2068                         public bool MoveNext ()
2069                         {
2070                                 return _baseEnumerator.MoveNext ();
2071                         }
2072
2073                         bool IEnumerator.MoveNext ()
2074                         {
2075                                 return _baseEnumerator.MoveNext ();
2076                         }
2077
2078                         public void Reset ()
2079                         {
2080                                 _baseEnumerator.Reset ();
2081                         }
2082
2083                         void IEnumerator.Reset ()
2084                         {
2085                                 _baseEnumerator.Reset ();
2086                         }
2087
2088                         private IEnumerator _baseEnumerator;
2089                 }
2090
2091                 public class NoCurrentEnumerator : IEnumerator
2092                 {
2093                         internal NoCurrentEnumerator (ArrayList arguments)
2094                         {
2095                                 IEnumerable temp = (IEnumerable) (arguments);
2096                                 _baseEnumerator = temp.GetEnumerator ();
2097                         }
2098
2099                         object IEnumerator.Current
2100                         {
2101                                 get { return _baseEnumerator.Current; }
2102                         }
2103
2104                         public bool MoveNext ()
2105                         {
2106                                 return _baseEnumerator.MoveNext ();
2107                         }
2108
2109                         bool IEnumerator.MoveNext ()
2110                         {
2111                                 return _baseEnumerator.MoveNext ();
2112                         }
2113
2114                         public void Reset ()
2115                         {
2116                                 _baseEnumerator.Reset ();
2117                         }
2118
2119                         void IEnumerator.Reset ()
2120                         {
2121                                 _baseEnumerator.Reset ();
2122                         }
2123
2124                         private IEnumerator _baseEnumerator;
2125                 }
2126
2127                 public class XmlArrayOnByteArrayType
2128                 {
2129                         [XmlArray]
2130                         [XmlArrayItem ("Byte", IsNullable =false)]
2131                         public byte [] Args;
2132                 }
2133
2134 #if NET_2_0
2135                 public class NullableContainer
2136                 {
2137                         [XmlElement (IsNullable = true)]
2138                         public int? NilInt;
2139                 }
2140
2141                 public class NullableContainer2
2142                 {
2143                         int? value;
2144
2145                         public int? NullableInt {
2146                                 get { return value; }
2147                                 set { this.value = value; }
2148                         }
2149                 }
2150
2151                 [XmlSchemaProvider ("GetXsdType")]
2152                 public class XmlSchemaProviderMissingMethodType : IXmlSerializable
2153                 {
2154                         public void ReadXml (XmlReader reader)
2155                         {
2156                         }
2157
2158                         public void WriteXml (XmlWriter writer)
2159                         {
2160                         }
2161
2162                         public XmlSchema GetSchema ()
2163                         {
2164                                 return null;
2165                         }
2166                 }
2167
2168                 [XmlSchemaProvider ("GetXsdType")]
2169                 public class XmlSchemaProviderNonStaticType : IXmlSerializable
2170                 {
2171                         public void ReadXml (XmlReader reader)
2172                         {
2173                         }
2174
2175                         public void WriteXml (XmlWriter writer)
2176                         {
2177                         }
2178
2179                         public XmlSchema GetSchema ()
2180                         {
2181                                 return null;
2182                         }
2183
2184                         public object GetXsdType ()
2185                         {
2186                                 return null;
2187                         }
2188                 }
2189
2190                 [XmlSchemaProvider ("GetXsdType")]
2191                 public class XmlSchemaProviderIncorrectReturnType : IXmlSerializable
2192                 {
2193                         public void ReadXml (XmlReader reader)
2194                         {
2195                         }
2196
2197                         public void WriteXml (XmlWriter writer)
2198                         {
2199                         }
2200
2201                         public XmlSchema GetSchema ()
2202                         {
2203                                 return null;
2204                         }
2205
2206                         public static object GetXsdType ()
2207                         {
2208                                 return null;
2209                         }
2210                 }
2211
2212                 [XmlSchemaProvider ("GetXsd")]
2213                 public class XmlSchemaProviderAndDefaultNamespaceType : IXmlSerializable
2214                 {
2215                         public static XmlQualifiedName GetXsd (XmlSchemaSet xss)
2216                         {
2217                                 XmlSchema xs = new XmlSchema ();
2218                                 xs.TargetNamespace = "urn:foo";
2219                                 XmlSchemaComplexType ct = new XmlSchemaComplexType ();
2220                                 ct.Name = "foo";
2221                                 xs.Items.Add (ct);
2222                                 xss.Add (xs);
2223                                 return new XmlQualifiedName ("foo", "urn:foo");
2224                         }
2225
2226                         public void WriteXml (XmlWriter write)
2227                         {
2228                         }
2229
2230                         public void ReadXml (XmlReader reader)
2231                         {
2232                         }
2233
2234                         public XmlSchema GetSchema ()
2235                         {
2236                                 return null;
2237                         }
2238                 }
2239
2240                 public class MyCollection : ICollection<string>
2241                 {
2242                         public int Count { get { return 0; } }
2243
2244                         public bool IsReadOnly { get { return false; } }
2245
2246                         public void Add (string s)
2247                         {
2248                         }
2249
2250                         public void Clear ()
2251                         {
2252                         }
2253
2254                         public bool Contains (string item)
2255                         {
2256                                 return false;
2257                         }
2258
2259                         public void CopyTo (string [] array, int arrayIndex)
2260                         {
2261                         }
2262
2263                         public IEnumerator<string> GetEnumerator ()
2264                         {
2265                                 throw new Exception ();
2266                         }
2267
2268                         IEnumerator IEnumerable.GetEnumerator ()
2269                         {
2270                                 return GetEnumerator ();
2271                         }
2272
2273                         public bool Remove (string item)
2274                         {
2275                                 return false;
2276                         }
2277                 }
2278 #endif
2279         }
2280 }
2281