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