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