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