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