2 // System.Xml.Serialization.SoapReflectionImporterTests
5 // Gert Driesen (drieseng@users.sourceforge.net)
11 using System.Collections;
12 using DefaultValueAttribute = System.ComponentModel.DefaultValueAttribute;
14 using System.Xml.Schema;
15 using System.Xml.Serialization;
17 using NUnit.Framework;
19 using MonoTests.System.Xml.TestClasses;
21 namespace MonoTests.System.XmlSerialization
24 public class SoapReflectionImporterTests
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/";
31 // these Map methods re-create the SoapReflectionImporter at every call.
33 private XmlTypeMapping Map (Type t)
35 SoapReflectionImporter ri = new SoapReflectionImporter ();
36 XmlTypeMapping tm = ri.ImportTypeMapping (t);
41 private XmlTypeMapping Map (Type t, string ns)
43 SoapReflectionImporter ri = new SoapReflectionImporter (ns);
44 XmlTypeMapping tm = ri.ImportTypeMapping (t);
49 private XmlTypeMapping Map (Type t, SoapAttributeOverrides overrides)
51 SoapReflectionImporter ri = new SoapReflectionImporter(overrides);
52 XmlTypeMapping tm = ri.ImportTypeMapping(t);
57 private XmlMembersMapping MembersMap (Type t, SoapAttributeOverrides overrides,
58 XmlReflectionMember [] members, bool inContainer, bool writeAccessors)
60 SoapReflectionImporter ri = new SoapReflectionImporter (overrides);
61 XmlMembersMapping mm = ri.ImportMembersMapping (null, null, members,
62 inContainer, writeAccessors);
68 public void TestIntTypeMapping ()
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");
78 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
79 public void TestIntTypeMapping_DefaultNamespace ()
81 XmlTypeMapping tm = Map (typeof (int), SomeNamespace);
82 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
84 tm = Map (typeof (int[]), SomeNamespace);
85 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
87 tm = Map (typeof (int[][]), SomeNamespace);
88 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
92 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
93 public void TestIntTypeMapping_Array ()
95 XmlTypeMapping tm = Map (typeof (int[]));
96 Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");
97 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
99 Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
101 Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");
103 Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
105 tm = Map (typeof (int[][]));
106 Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");
107 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
109 Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");
111 Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");
113 Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");
117 public void TestStringTypeMapping ()
119 XmlTypeMapping tm = Map (typeof (string));
120 Assert.AreEqual ("string", tm.ElementName, "#1");
121 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
122 Assert.AreEqual ("String", tm.TypeName, "#3");
123 Assert.AreEqual ("System.String", tm.TypeFullName, "#4");
127 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
128 public void TestStringTypeMapping_DefaultNamespace ()
130 XmlTypeMapping tm = Map (typeof (string), SomeNamespace);
131 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
133 tm = Map (typeof (string[]), SomeNamespace);
134 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
136 tm = Map (typeof (string[][]), SomeNamespace);
137 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
141 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
142 public void TestStringTypeMapping_Array ()
144 XmlTypeMapping tm = Map (typeof (string[]));
145 Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");
146 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
148 Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");
150 Assert.AreEqual ("String[]", tm.TypeName, "#A3");
152 Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");
154 tm = Map (typeof (string[][]));
155 Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");
156 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
158 Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");
160 Assert.AreEqual ("String[][]", tm.TypeName, "#B3");
162 Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");
166 public void TestObjectTypeMapping ()
168 XmlTypeMapping tm = Map (typeof (object));
169 Assert.AreEqual ("anyType", tm.ElementName, "#1");
170 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
171 Assert.AreEqual ("Object", tm.TypeName, "#3");
172 Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");
176 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
177 public void TestObjectTypeMapping_DefaultNamespace ()
179 XmlTypeMapping tm = Map (typeof (object), SomeNamespace);
180 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
182 tm = Map (typeof (object[]), SomeNamespace);
183 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
185 tm = Map (typeof (object[][]), SomeNamespace);
186 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
190 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
191 public void TestObjectTypeMapping_Array ()
193 XmlTypeMapping tm = Map (typeof (object[]));
194 Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");
195 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
197 Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");
199 Assert.AreEqual ("Object[]", tm.TypeName, "#A3");
201 Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");
203 tm = Map (typeof (object[][]));
204 Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");
205 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
207 Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");
209 Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");
211 Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");
215 public void TestByteTypeMapping ()
217 XmlTypeMapping tm = Map (typeof (byte));
218 Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");
219 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
220 Assert.AreEqual ("Byte", tm.TypeName, "#3");
221 Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");
225 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
226 public void TestByteTypeMapping_DefaultNamespace ()
228 XmlTypeMapping tm = Map (typeof (byte), SomeNamespace);
229 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
231 tm = Map (typeof (byte[]), SomeNamespace);
232 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
234 tm = Map (typeof (byte[][]), SomeNamespace);
235 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
239 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
240 public void TestByteTypeMapping_Array ()
242 XmlTypeMapping tm = Map (typeof (byte[]));
243 Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");
244 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#A2");
245 Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");
246 Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");
248 tm = Map (typeof (byte[][]));
249 Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");
250 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
252 Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");
254 Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");
256 Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");
260 public void TestBoolTypeMapping ()
262 XmlTypeMapping tm = Map (typeof (bool));
263 Assert.AreEqual ("boolean", tm.ElementName, "#1");
264 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
265 Assert.AreEqual ("Boolean", tm.TypeName, "#3");
266 Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");
270 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
271 public void TestBoolTypeMapping_DefaultNamespace ()
273 XmlTypeMapping tm = Map (typeof (bool), "http://somenamespace");
274 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
276 tm = Map (typeof (bool[]), SomeNamespace);
277 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
279 tm = Map (typeof (bool[][]), SomeNamespace);
280 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
284 public void TestShortTypeMapping ()
286 XmlTypeMapping tm = Map (typeof (short));
287 Assert.AreEqual ("short", tm.ElementName, "#1");
288 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
289 Assert.AreEqual ("Int16", tm.TypeName, "#3");
290 Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");
294 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
295 public void TestShortTypeMapping_DefaultNamespace ()
297 XmlTypeMapping tm = Map (typeof (short), SomeNamespace);
298 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
300 tm = Map (typeof (short[]), SomeNamespace);
301 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
303 tm = Map (typeof (short[][]), SomeNamespace);
304 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
308 public void TestUnsignedShortTypeMapping ()
310 XmlTypeMapping tm = Map (typeof (ushort));
311 Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");
312 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
313 Assert.AreEqual ("UInt16", tm.TypeName, "#3");
314 Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");
318 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
319 public void TestUnsignedShortTypeMapping_DefaultNamespace ()
321 XmlTypeMapping tm = Map (typeof (ushort), SomeNamespace);
322 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
324 tm = Map (typeof (ushort[]), SomeNamespace);
325 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
327 tm = Map (typeof (ushort[][]), SomeNamespace);
328 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
332 public void TestUIntTypeMapping ()
334 XmlTypeMapping tm = Map (typeof (uint));
335 Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");
336 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
337 Assert.AreEqual ("UInt32", tm.TypeName, "#3");
338 Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");
342 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
343 public void TestUIntTypeMapping_DefaultNamespace ()
345 XmlTypeMapping tm = Map (typeof (uint), SomeNamespace);
346 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
348 tm = Map (typeof (uint[]), SomeNamespace);
349 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
351 tm = Map (typeof (uint[][]), SomeNamespace);
352 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
356 public void TestLongTypeMapping ()
358 XmlTypeMapping tm = Map (typeof (long));
359 Assert.AreEqual ("long", tm.ElementName, "#1");
360 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
361 Assert.AreEqual ("Int64", tm.TypeName, "#3");
362 Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");
366 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
367 public void TestLongTypeMapping_DefaultNamespace ()
369 XmlTypeMapping tm = Map (typeof (long), SomeNamespace);
370 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
372 tm = Map (typeof (long[]), SomeNamespace);
373 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
375 tm = Map (typeof (long[][]), SomeNamespace);
376 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
380 public void TestULongTypeMapping ()
382 XmlTypeMapping tm = Map (typeof (ulong));
383 Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");
384 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
385 Assert.AreEqual ("UInt64", tm.TypeName, "#3");
386 Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");
390 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
391 public void TestULongTypeMapping_DefaultNamespace ()
393 XmlTypeMapping tm = Map (typeof (ulong), SomeNamespace);
394 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
396 tm = Map (typeof (ulong[]), SomeNamespace);
397 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
399 tm = Map (typeof (ulong[][]), SomeNamespace);
400 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
404 public void TestFloatTypeMapping ()
406 XmlTypeMapping tm = Map (typeof (float));
407 Assert.AreEqual ("float", tm.ElementName, "#1");
408 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
409 Assert.AreEqual ("Single", tm.TypeName, "#3");
410 Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");
414 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
415 public void TestFloatTypeMapping_DefaultNamespace ()
417 XmlTypeMapping tm = Map (typeof (float), SomeNamespace);
418 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
420 tm = Map (typeof (float[]), SomeNamespace);
421 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
423 tm = Map (typeof (float[][]), SomeNamespace);
424 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
428 public void TestDoubleTypeMapping ()
430 XmlTypeMapping tm = Map (typeof (double));
431 Assert.AreEqual ("double", tm.ElementName, "#1");
432 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
433 Assert.AreEqual ("Double", tm.TypeName, "#3");
434 Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");
438 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
439 public void TestDoubleTypeMapping_DefaultNamespace ()
441 XmlTypeMapping tm = Map (typeof (double), SomeNamespace);
442 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
444 tm = Map (typeof (double[]), SomeNamespace);
445 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
447 tm = Map (typeof (double[][]), SomeNamespace);
448 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
452 public void TestDateTimeTypeMapping ()
454 XmlTypeMapping tm = Map (typeof (DateTime));
455 Assert.AreEqual ("dateTime", tm.ElementName, "#1");
456 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
457 Assert.AreEqual ("DateTime", tm.TypeName, "#3");
458 Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");
462 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
463 public void TestDateTimeTypeMapping_DefaultNamespace ()
465 XmlTypeMapping tm = Map (typeof (DateTime), SomeNamespace);
466 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
468 tm = Map (typeof (DateTime[]), SomeNamespace);
469 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
471 tm = Map (typeof (DateTime[][]), SomeNamespace);
472 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
476 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
477 public void TestDateTimeTypeMapping_Array ()
479 XmlTypeMapping tm = Map (typeof (DateTime[]));
480 Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");
481 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
483 Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");
485 Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");
487 Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");
489 tm = Map (typeof (DateTime[][]));
490 Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");
491 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
493 Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");
495 Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");
497 Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");
501 public void TestGuidTypeMapping ()
503 XmlTypeMapping tm = Map (typeof (Guid));
504 Assert.AreEqual ("guid", tm.ElementName, "#1");
505 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#2");
506 Assert.AreEqual ("Guid", tm.TypeName, "#3");
507 Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");
511 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
512 public void TestGuidTypeMapping_DefaultNamespace ()
514 XmlTypeMapping tm = Map (typeof (Guid), SomeNamespace);
515 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
517 tm = Map (typeof (Guid[]), SomeNamespace);
518 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
520 tm = Map (typeof (Guid[][]), SomeNamespace);
521 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
525 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
526 public void TestGuidTypeMapping_Array ()
528 XmlTypeMapping tm = Map (typeof (Guid[]));
529 Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");
530 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
532 Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");
534 Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");
536 Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");
538 tm = Map (typeof (Guid[][]));
539 Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");
540 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
542 Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");
544 Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");
546 Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");
550 public void TestDecimalTypeMapping ()
552 XmlTypeMapping tm = Map (typeof (decimal));
553 Assert.AreEqual ("decimal", tm.ElementName, "#1");
554 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
555 Assert.AreEqual ("Decimal", tm.TypeName, "#3");
556 Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");
560 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
561 public void TestDecimalTypeMapping_DefaultNamespace ()
563 XmlTypeMapping tm = Map (typeof (decimal), SomeNamespace);
564 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
566 tm = Map (typeof (decimal[]), SomeNamespace);
567 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
569 tm = Map (typeof (decimal[][]), SomeNamespace);
570 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
574 public void TestXmlQualifiedNameTypeMapping ()
576 XmlTypeMapping tm = Map (typeof (XmlQualifiedName));
577 Assert.AreEqual ("QName", tm.ElementName, "#1");
578 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
579 Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");
580 Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");
584 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
585 public void TestXmlQualifiedNameTypeMapping_DefaultNamespace ()
587 XmlTypeMapping tm = Map (typeof (XmlQualifiedName), SomeNamespace);
588 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
590 tm = Map (typeof (XmlQualifiedName[]), SomeNamespace);
591 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
593 tm = Map (typeof (XmlQualifiedName[][]), SomeNamespace);
594 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
598 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
599 public void TestXmlQualifiedNameTypeMapping_Array ()
601 XmlTypeMapping tm = Map (typeof (XmlQualifiedName[]));
602 Assert.AreEqual ("ArrayOfQName", tm.ElementName, "#A1");
603 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
605 Assert.AreEqual ("ArrayOfXmlQualifiedName", tm.TypeName, "#A3");
607 Assert.AreEqual ("XmlQualifiedName[]", tm.TypeName, "#A3");
609 Assert.AreEqual ("System.Xml.XmlQualifiedName[]", tm.TypeFullName, "#A4");
611 tm = Map (typeof (XmlQualifiedName[][]));
612 Assert.AreEqual ("ArrayOfArrayOfQName", tm.ElementName, "#B1");
613 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
615 Assert.AreEqual ("ArrayOfArrayOfXmlQualifiedName", tm.TypeName, "#B3");
617 Assert.AreEqual ("XmlQualifiedName[][]", tm.TypeName, "#B3");
619 Assert.AreEqual ("System.Xml.XmlQualifiedName[][]", tm.TypeFullName, "#B4");
623 public void TestSByteTypeMapping ()
625 XmlTypeMapping tm = Map (typeof (sbyte));
626 Assert.AreEqual ("byte", tm.ElementName, "#1");
627 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
628 Assert.AreEqual ("SByte", tm.TypeName, "#3");
629 Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");
633 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
634 public void TestSByteTypeMapping_DefaultNamespace ()
636 XmlTypeMapping tm = Map (typeof (sbyte), SomeNamespace);
637 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
639 tm = Map (typeof (sbyte[]), SomeNamespace);
640 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
642 tm = Map (typeof (sbyte[][]), SomeNamespace);
643 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
647 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
648 public void TestSByteTypeMapping_Array ()
650 XmlTypeMapping tm = Map (typeof (sbyte[]));
651 Assert.AreEqual ("ArrayOfByte", tm.ElementName, "#A1");
652 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
654 Assert.AreEqual ("ArrayOfSByte", tm.TypeName, "#A3");
656 Assert.AreEqual ("SByte[]", tm.TypeName, "#A3");
658 Assert.AreEqual ("System.SByte[]", tm.TypeFullName, "#A4");
660 tm = Map (typeof (sbyte[][]));
661 Assert.AreEqual ("ArrayOfArrayOfByte", tm.ElementName, "#B1");
662 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
664 Assert.AreEqual ("ArrayOfArrayOfSByte", tm.TypeName, "#B3");
666 Assert.AreEqual ("SByte[][]", tm.TypeName, "#B3");
668 Assert.AreEqual ("System.SByte[][]", tm.TypeFullName, "#B4");
672 public void TestCharTypeMapping()
674 XmlTypeMapping tm = Map (typeof (char));
675 Assert.AreEqual ("char", tm.ElementName, "#1");
676 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#2");
677 Assert.AreEqual ("Char", tm.TypeName, "#3");
678 Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");
682 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
683 public void TestCharTypeMapping_DefaultNamespace ()
685 XmlTypeMapping tm = Map (typeof (char), SomeNamespace);
686 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
688 tm = Map (typeof (char[]), SomeNamespace);
689 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
691 tm = Map (typeof (char[][]), SomeNamespace);
692 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
696 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
697 public void TestCharTypeMapping_Array ()
699 XmlTypeMapping tm = Map (typeof (char[]));
700 Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");
701 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
703 Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");
705 Assert.AreEqual ("Char[]", tm.TypeName, "#A3");
707 Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");
709 tm = Map (typeof (char[][]));
710 Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");
711 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
713 Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");
715 Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");
717 Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");
721 public void TestXmlNodeTypeMapping ()
724 Map (typeof (XmlNode));
726 } catch (NotSupportedException) {
727 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
731 Map (typeof (XmlNode[]));
733 } catch (NotSupportedException) {
734 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
738 Map (typeof (XmlNode[][]));
740 } catch (NotSupportedException) {
741 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
746 public void TestXmlNodeTypeMapping_DefaultNamespace ()
749 Map (typeof (XmlNode), SomeNamespace);
751 } catch (NotSupportedException) {
752 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
756 Map (typeof (XmlNode[]), SomeNamespace);
758 } catch (NotSupportedException) {
759 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
763 Map (typeof (XmlNode[][]), SomeNamespace);
765 } catch (NotSupportedException) {
766 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
771 public void TestXmlElementTypeMapping ()
774 Map (typeof (XmlElement));
776 } catch (NotSupportedException) {
777 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
781 Map (typeof (XmlElement[]));
783 } catch (NotSupportedException) {
784 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
788 Map (typeof (XmlElement[][]));
790 } catch (NotSupportedException) {
791 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
796 public void TestXmlElementTypeMapping_DefaultNamespace ()
799 Map (typeof (XmlElement), SomeNamespace);
801 } catch (NotSupportedException) {
802 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
806 Map (typeof (XmlElement[]), SomeNamespace);
808 } catch (NotSupportedException) {
809 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
813 Map (typeof (XmlElement[][]), SomeNamespace);
815 } catch (NotSupportedException) {
816 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
821 public void TestXmlNotationTypeMapping ()
824 Map (typeof (XmlNotation));
826 } catch (NotSupportedException) {
827 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
831 Map (typeof (XmlNotation[]));
833 } catch (NotSupportedException) {
834 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
838 Map (typeof (XmlNotation[][]));
840 } catch (NotSupportedException) {
841 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
846 public void TestXmlNotationTypeMapping_DefaultNamespace ()
849 Map (typeof (XmlNotation), SomeNamespace);
851 } catch (NotSupportedException) {
852 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
856 Map (typeof (XmlNotation[]), SomeNamespace);
858 } catch (NotSupportedException) {
859 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
863 Map (typeof (XmlNotation[][]), SomeNamespace);
865 } catch (NotSupportedException) {
866 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
871 [ExpectedException (typeof (NotSupportedException))]
872 public void TestXmlSerializableTypeMapping ()
874 Map (typeof (Employee));
878 [Category ("NotWorking")]
879 [ExpectedException (typeof (NotSupportedException))]
880 public void TestClassTypeMapping_NestedStruct ()
882 Map (typeof (NestedStruct));
886 [ExpectedException (typeof (ArgumentNullException))]
887 public void TestNullTypeMapping()
893 [ExpectedException (typeof (ArgumentNullException))]
894 public void TestNullTypeMapping_DefaultNamespace ()
896 Map (null, SomeNamespace);
900 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
901 public void TestStructTypeMapping ()
903 XmlTypeMapping tm = Map (typeof (TimeSpan));
904 Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");
905 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
906 Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");
907 Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");
911 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
912 public void TestStructTypeMapping_DefaultNamespace ()
914 XmlTypeMapping tm = Map (typeof (TimeSpan), SomeNamespace);
915 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
918 tm = Map (typeof (TimeSpan[]), SomeNamespace);
920 } catch (NotSupportedException) {
924 tm = Map (typeof (TimeSpan[][]), SomeNamespace);
926 } catch (NotSupportedException) {
931 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
932 [ExpectedException (typeof (NotSupportedException))] // Arrays of structs are not supported with encoded SOAP.
933 public void TestStructTypeMapping_Array ()
935 Map (typeof (TimeSpan[]));
939 public void TestEnumTypeMapping ()
941 XmlTypeMapping tm = Map (typeof (AttributeTargets));
942 Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");
943 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
944 Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");
945 Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");
949 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
950 public void TestEnumTypeMapping_DefaultNamespace ()
952 XmlTypeMapping tm = Map (typeof (AttributeTargets), SomeNamespace);
953 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
955 tm = Map (typeof (AttributeTargets[]), SomeNamespace);
956 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
958 tm = Map (typeof (AttributeTargets[][]), SomeNamespace);
959 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
963 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
964 public void TestEnumTypeMapping_Array ()
966 XmlTypeMapping tm = Map (typeof (AttributeTargets[]));
967 Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");
968 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
970 Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");
972 Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");
974 Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");
976 tm = Map (typeof (AttributeTargets[][]));
977 Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");
978 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
980 Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");
982 Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");
984 Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");
988 public void TestClassTypeMapping()
990 XmlTypeMapping tm = Map (typeof (SimpleClass));
991 Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");
992 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
993 Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");
994 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");
998 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
999 public void TestClassTypeMapping_DefaultNamespace ()
1001 XmlTypeMapping tm = Map (typeof (SimpleClass), SomeNamespace);
1002 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
1004 tm = Map (typeof (SimpleClass[]), SomeNamespace);
1005 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
1007 tm = Map (typeof (SimpleClass[][]), SomeNamespace);
1008 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
1012 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1013 public void TestClassTypeMapping_Array ()
1015 XmlTypeMapping tm = Map (typeof (SimpleClass[]));
1016 Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");
1017 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1019 Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");
1021 Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");
1023 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");
1025 tm = Map (typeof (SimpleClass[][]));
1026 Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
1027 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1029 Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");
1031 Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");
1033 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
1038 [Category ("NotDotNet")] // wrong error message is reported in .NET 1.1
1040 public void TypeMapping_Attribute_ComplexType ()
1042 SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Names")[0]);
1043 attrs.SoapAttribute = new SoapAttributeAttribute (); // SoapAttribute cannot be used to encode complex types
1044 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
1045 overrides.Add (typeof (Field_Encoded), "Names", attrs);
1048 Map (typeof (Field_Encoded), overrides);
1049 Assert.Fail ("#A1");
1050 } catch (InvalidOperationException ex) {
1051 // Cannot serialize member 'Names' of type System.String[].
1052 // SoapAttribute cannot be used to encode complex types.
1053 Assert.IsNotNull (ex.Message, "#A2");
1054 Assert.IsTrue (ex.Message.IndexOf (typeof (string[]).FullName) != -1, "#A3");
1055 Assert.IsTrue (ex.Message.IndexOf ("SoapAttribute") != -1, "#A4");
1056 Assert.IsNull (ex.InnerException, "#A5");
1061 public void TypeMapping_Field ()
1063 XmlTypeMapping tm = Map (typeof (Field));
1064 Assert.AreEqual ("Field", tm.ElementName, "#1");
1065 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1066 Assert.AreEqual ("Field", tm.TypeName, "#3");
1067 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
1071 public void TypeMapping_Field_DefaultNamespace ()
1073 XmlTypeMapping tm = Map (typeof (Field), SomeNamespace);
1074 Assert.AreEqual ("Field", tm.ElementName, "#1");
1075 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
1076 Assert.AreEqual ("Field", tm.TypeName, "#3");
1077 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
1081 public void TypeMapping_Field_Encoded ()
1083 XmlTypeMapping tm = Map (typeof (Field_Encoded));
1084 Assert.AreEqual ("field", tm.ElementName, "#1");
1085 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
1086 Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
1087 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
1091 public void TypeMapping_Field_Encoded_DefaultNamespace ()
1093 XmlTypeMapping tm = Map (typeof (Field_Encoded), AnotherNamespace);
1094 Assert.AreEqual ("field", tm.ElementName, "#1");
1095 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
1096 Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
1097 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
1101 public void TypeMapping_FlagEnum ()
1103 XmlTypeMapping tm = Map (typeof (FlagEnum));
1104 Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
1105 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1106 Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
1107 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
1111 public void TypeMapping_FlagEnum_DefaultNamespace ()
1113 XmlTypeMapping tm = Map (typeof (FlagEnum), SomeNamespace);
1114 Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
1115 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
1116 Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
1117 Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
1121 [ExpectedException (typeof (NotSupportedException))]
1122 public void TypeMapping_IDictionary ()
1124 // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer
1125 // is not supported because it implements IDictionary.
1126 Map (typeof (DictionaryWithIndexer));
1130 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1131 public void TypeMapping_IEnumerable_SimpleClass ()
1133 XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
1134 Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
1135 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1136 Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
1137 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
1139 tm = Map (typeof (SimpleClassEnumerable[]));
1140 Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
1141 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1143 Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
1145 Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
1147 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
1149 tm = Map (typeof (SimpleClassEnumerable[][]));
1150 Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
1151 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1153 Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
1155 Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
1157 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
1161 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1162 public void TypeMapping_IEnumerable_Object ()
1164 XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
1165 Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1166 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1167 Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
1168 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
1170 tm = Map (typeof (ObjectEnumerable[]));
1171 Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1172 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1174 Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
1176 Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
1178 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
1180 tm = Map (typeof (ObjectEnumerable[][]));
1181 Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1182 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1184 Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
1186 Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
1188 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
1192 [ExpectedException (typeof (InvalidOperationException))]
1193 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
1195 Map (typeof (ObjectEnumerableNoMatchingAddMethod));
1199 [ExpectedException (typeof (InvalidOperationException))]
1200 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
1202 Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
1206 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1207 public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
1209 XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
1210 Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1211 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1212 Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
1213 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
1215 tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
1216 Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1217 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1219 Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
1221 Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
1223 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
1225 tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
1226 Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1227 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1229 Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
1231 Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
1233 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
1237 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1239 [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
1241 public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
1243 XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
1244 Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1245 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1246 Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
1247 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
1249 tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
1250 Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1251 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1253 Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
1255 Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
1257 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
1259 tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
1260 Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1261 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1263 Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
1265 Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
1267 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
1271 [ExpectedException (typeof (InvalidOperationException))]
1272 public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
1274 Map (typeof (ObjectCollectionNoMatchingAddMethod));
1278 [ExpectedException (typeof (InvalidOperationException))]
1279 public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
1281 Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
1285 [ExpectedException (typeof (InvalidOperationException))]
1286 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
1288 Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
1292 [ExpectedException (typeof (InvalidOperationException))]
1293 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
1295 Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
1299 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1300 public void TypeMapping_ICollection_SimpleClass ()
1302 XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
1303 Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
1304 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1305 Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
1306 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
1308 tm = Map (typeof (SimpleClassCollection[]));
1309 Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
1310 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1312 Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
1314 Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
1316 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
1318 tm = Map (typeof (SimpleClassCollection[][]));
1319 Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
1320 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1322 Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
1324 Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
1326 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
1330 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1331 public void TypeMapping_ICollection_Object ()
1333 XmlTypeMapping tm = Map (typeof (ObjectCollection));
1334 Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1335 Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1336 Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
1337 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
1339 tm = Map (typeof (ObjectCollection[]));
1340 Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1341 Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1343 Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
1345 Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
1347 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
1349 tm = Map (typeof (ObjectCollection[][]));
1350 Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1351 Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1353 Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
1355 Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
1357 Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
1361 [ExpectedException (typeof (InvalidOperationException))]
1362 public void TypeMapping_ICollection_Object_NoIntIndexer ()
1364 Map (typeof (ObjectCollectionNoIntIndexer));
1368 [ExpectedException (typeof (InvalidOperationException))]
1369 public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
1371 Map (typeof (ObjectCollectionNoIntIndexer[]));
1375 [ExpectedException (typeof (InvalidOperationException))]
1376 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
1378 Map (typeof (SimpleClassCollectionNoIntIndexer));
1382 [ExpectedException (typeof (InvalidOperationException))]
1383 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
1385 Map (typeof (SimpleClassCollectionNoIntIndexer[]));
1389 public void TypeMapping_InvalidDefault ()
1391 SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Modifiers")[0]);
1392 attrs.SoapDefaultValue = 2; // not a defined enum value
1393 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
1394 overrides.Add (typeof (Field_Encoded), "Modifiers", attrs);
1397 Map (typeof (Field_Encoded), overrides);
1398 Assert.Fail ("#A1");
1399 } catch (InvalidOperationException ex) {
1400 // Enum System.Int32 cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1401 Assert.IsNotNull (ex.Message, "#A2");
1402 Assert.IsTrue (ex.Message.IndexOf (typeof (int).FullName) != -1, "#A3");
1403 Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#A4");
1404 Assert.IsNull (ex.InnerException, "#A5");
1407 attrs.SoapDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
1410 Map (typeof (Field_Encoded), overrides);
1411 Assert.Fail ("#B1");
1412 } catch (InvalidOperationException ex) {
1413 // Enum System.String cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1414 Assert.IsNotNull (ex.Message, "#B2");
1415 Assert.IsTrue (ex.Message.IndexOf (typeof (string).FullName) != -1, "#B3");
1416 Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#B4");
1417 Assert.IsNull (ex.InnerException, "#B5");
1420 attrs.SoapDefaultValue = EnumDefaultValueNF.e2; // other enum type
1423 Map (typeof (Field_Encoded), overrides);
1424 Assert.Fail ("#C1");
1425 } catch (InvalidOperationException ex) {
1426 // Enum MonoTests.System.Xml.TestClasses.EnumDefaultValueNF cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1427 Assert.IsNotNull (ex.Message, "#C2");
1428 Assert.IsTrue (ex.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C3");
1429 Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C4");
1430 Assert.IsNull (ex.InnerException, "#C5");
1433 attrs.SoapDefaultValue = (MapModifiers) 20; // non-existing enum value
1436 Map (typeof (Field_Encoded), overrides);
1437 Assert.Fail ("#D1");
1438 } catch (InvalidOperationException ex) {
1439 // Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1440 Assert.IsNotNull (ex.Message, "#D2");
1441 Assert.IsTrue (ex.Message.IndexOf ("'20'") != -1, "#D3");
1442 Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D4");
1443 Assert.IsNull (ex.InnerException, "#D5");
1448 [Category ("NotWorking")]
1449 public void TestImportMembersMapping()
1451 Type type = typeof (SimpleClass);
1452 SoapAttributes attrs = new SoapAttributes ();
1453 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
1454 overrides.Add (typeof (SimpleClass), attrs);
1456 XmlReflectionMember[] members = new XmlReflectionMember[0];
1457 XmlMembersMapping mm;
1460 mm = MembersMap(type, overrides, members, true, true);
1461 Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
1467 XmlReflectionMember rm = new XmlReflectionMember();
1468 rm.IsReturnValue = false;
1469 rm.MemberName = "something";
1470 rm.MemberType = typeof(string);
1471 members = new XmlReflectionMember[1];
1474 mm = MembersMap(type, overrides, members, false, false);
1476 Equals(mm.Count, 1);
1478 XmlMemberMapping smm = mm[0];
1479 Assert.IsFalse (smm.Any, "#1");
1480 Assert.AreEqual ("something", smm.ElementName, "#2");
1481 Assert.AreEqual ("something", smm.MemberName, "#3");
1482 Assert.IsNull (smm.Namespace, "#4");
1483 Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
1484 Assert.AreEqual ("string", smm.TypeName, "#6");
1485 Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");
1488 rm = new XmlReflectionMember();
1489 rm.IsReturnValue = false;
1490 rm.MemberName = "nothing";
1491 rm.MemberType = typeof(string);
1492 members = new XmlReflectionMember[1];
1495 mm = MembersMap(type, overrides, members, false, false);
1496 Assert.AreEqual (1 , mm.Count, "#8");
1499 public class Employee : IXmlSerializable
1501 private string _firstName;
1502 private string _lastName;
1503 private string _address;
1505 public XmlSchema GetSchema ()
1510 public void WriteXml (XmlWriter writer)
1512 writer.WriteStartElement ("employee", "urn:devx-com");
1513 writer.WriteAttributeString ("firstName", _firstName);
1514 writer.WriteAttributeString ("lastName", _lastName);
1515 writer.WriteAttributeString ("address", _address);
1516 writer.WriteEndElement ();
1519 public void ReadXml (XmlReader reader)
1521 XmlNodeType type = reader.MoveToContent ();
1522 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
1523 _firstName = reader["firstName"];
1524 _lastName = reader["lastName"];
1525 _address = reader["address"];
1530 public class NestedStruct
1532 public TimeSpan Period = TimeSpan.MaxValue;
1535 public class ObjectEnumerable : IEnumerable
1537 public void Add (int value)
1541 public void Add (object value)
1545 public IEnumerator GetEnumerator ()
1547 return new ArrayList ().GetEnumerator ();
1551 public class SimpleClassEnumerable : IEnumerable
1553 public void Add (int value)
1557 public void Add (object value)
1561 IEnumerator IEnumerable.GetEnumerator ()
1563 return GetEnumerator ();
1566 public SimpleClassEnumerator GetEnumerator ()
1568 return new SimpleClassEnumerator (new ArrayList ());
1572 public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
1574 public void Add (object value)
1578 IEnumerator IEnumerable.GetEnumerator ()
1580 return new ArrayList ().GetEnumerator ();
1584 public class SimpleClassEnumerablePrivateCurrent : IEnumerable
1586 public void Add (object value)
1590 IEnumerator IEnumerable.GetEnumerator ()
1592 return GetEnumerator ();
1595 public NoCurrentEnumerator GetEnumerator ()
1597 return new NoCurrentEnumerator (new ArrayList ());
1601 // GetEnumerator().Current returns object, but there's no corresponding
1602 // Add (System.Object) method
1603 public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
1605 public void Add (int value)
1609 public IEnumerator GetEnumerator ()
1611 return new ArrayList ().GetEnumerator ();
1615 // GetEnumerator().Current returns SimpleClass, but there's no
1616 // corresponding Add (SimpleClass) method
1617 public class SimpleClassCollectionNoMatchingAddMethod : ICollection
1619 public SimpleClass this[int index] {
1621 return (SimpleClass) _list[index];
1626 get { return _list.Count; }
1629 public bool IsSynchronized {
1630 get { return _list.IsSynchronized; }
1633 public object SyncRoot {
1634 get { return _list.SyncRoot; }
1637 public void CopyTo (Array array, int index)
1639 _list.CopyTo (array, index);
1642 IEnumerator IEnumerable.GetEnumerator()
1644 return GetEnumerator ();
1647 public SimpleClassEnumerator GetEnumerator ()
1649 return new SimpleClassEnumerator (_list);
1652 private ArrayList _list = new ArrayList ();
1655 // GetEnumerator().Current returns object, but there's no corresponding
1656 // Add (System.Object) method
1657 public class ObjectCollectionNoMatchingAddMethod : ICollection
1659 public object this[int index] {
1661 return _list[index];
1666 get { return _list.Count; }
1669 public bool IsSynchronized {
1670 get { return _list.IsSynchronized; }
1673 public object SyncRoot {
1674 get { return _list.SyncRoot; }
1677 public void CopyTo (Array array, int index)
1679 _list.CopyTo (array, index);
1682 IEnumerator IEnumerable.GetEnumerator ()
1684 return GetEnumerator ();
1687 public IEnumerator GetEnumerator ()
1689 return _list.GetEnumerator ();
1692 private ArrayList _list = new ArrayList ();
1695 // Does not have int indexer.
1696 public class SimpleClassCollectionNoIntIndexer : ICollection
1698 public SimpleClass this[string name] {
1700 return new SimpleClass ();
1705 get { return _list.Count; }
1708 public bool IsSynchronized {
1709 get { return _list.IsSynchronized; }
1712 public object SyncRoot {
1713 get { return _list.SyncRoot; }
1716 public void CopyTo (Array array, int index)
1718 _list.CopyTo (array, index);
1721 IEnumerator IEnumerable.GetEnumerator ()
1723 return GetEnumerator ();
1726 public SimpleClassEnumerator GetEnumerator ()
1728 return new SimpleClassEnumerator (_list);
1731 public void Add (SimpleClass value)
1736 private ArrayList _list = new ArrayList ();
1739 // Does not have int indexer.
1740 public class ObjectCollectionNoIntIndexer : ICollection
1742 public object this[string name] {
1744 return new SimpleClass ();
1749 get { return _list.Count; }
1752 public bool IsSynchronized {
1753 get { return _list.IsSynchronized; }
1756 public object SyncRoot {
1757 get { return _list.SyncRoot; }
1760 public void CopyTo (Array array, int index)
1762 _list.CopyTo (array, index);
1765 public IEnumerator GetEnumerator ()
1767 return _list.GetEnumerator ();
1770 public void Add (object value)
1775 private ArrayList _list = new ArrayList ();
1778 public class SimpleClassCollection : ICollection
1780 public SimpleClass this[int index] {
1782 return (SimpleClass) _list[index];
1787 get { return _list.Count; }
1790 public bool IsSynchronized {
1791 get { return _list.IsSynchronized; }
1794 public object SyncRoot {
1795 get { return _list.SyncRoot; }
1798 public void CopyTo (Array array, int index)
1800 _list.CopyTo (array, index);
1803 IEnumerator IEnumerable.GetEnumerator ()
1805 return GetEnumerator ();
1808 public SimpleClassEnumerator GetEnumerator ()
1810 return new SimpleClassEnumerator (_list);
1813 public void Add (SimpleClass value)
1818 private ArrayList _list = new ArrayList ();
1821 public class ObjectCollection : ICollection
1823 public object this[int name] {
1825 return new SimpleClass ();
1831 get { return _list.Count; }
1834 public bool IsSynchronized
1836 get { return _list.IsSynchronized; }
1839 public object SyncRoot
1841 get { return _list.SyncRoot; }
1844 public void CopyTo (Array array, int index)
1846 _list.CopyTo (array, index);
1849 public IEnumerator GetEnumerator ()
1851 return _list.GetEnumerator ();
1854 public void Add (object value)
1859 private ArrayList _list = new ArrayList ();
1862 public class SimpleClassEnumerator : IEnumerator
1864 internal SimpleClassEnumerator (ArrayList arguments)
1866 IEnumerable temp = (IEnumerable) (arguments);
1867 _baseEnumerator = temp.GetEnumerator ();
1869 public SimpleClass Current
1871 get { return (SimpleClass) _baseEnumerator.Current; }
1874 object IEnumerator.Current
1876 get { return _baseEnumerator.Current; }
1879 public bool MoveNext ()
1881 return _baseEnumerator.MoveNext ();
1884 bool IEnumerator.MoveNext ()
1886 return _baseEnumerator.MoveNext ();
1889 public void Reset ()
1891 _baseEnumerator.Reset ();
1894 void IEnumerator.Reset ()
1896 _baseEnumerator.Reset ();
1899 private IEnumerator _baseEnumerator;
1902 public class NoCurrentEnumerator : IEnumerator
1904 internal NoCurrentEnumerator (ArrayList arguments)
1906 IEnumerable temp = (IEnumerable) (arguments);
1907 _baseEnumerator = temp.GetEnumerator ();
1910 object IEnumerator.Current
1912 get { return _baseEnumerator.Current; }
1915 public bool MoveNext ()
1917 return _baseEnumerator.MoveNext ();
1920 bool IEnumerator.MoveNext ()
1922 return _baseEnumerator.MoveNext ();
1925 public void Reset ()
1927 _baseEnumerator.Reset ();
1930 void IEnumerator.Reset ()
1932 _baseEnumerator.Reset ();
1935 private IEnumerator _baseEnumerator;