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");
98 Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
99 Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
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");
109 public void TestStringTypeMapping ()
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");
119 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
120 public void TestStringTypeMapping_DefaultNamespace ()
122 XmlTypeMapping tm = Map (typeof (string), SomeNamespace);
123 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
125 tm = Map (typeof (string[]), SomeNamespace);
126 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
128 tm = Map (typeof (string[][]), SomeNamespace);
129 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
133 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
134 public void TestStringTypeMapping_Array ()
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");
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");
150 public void TestObjectTypeMapping ()
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");
160 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
161 public void TestObjectTypeMapping_DefaultNamespace ()
163 XmlTypeMapping tm = Map (typeof (object), SomeNamespace);
164 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
166 tm = Map (typeof (object[]), SomeNamespace);
167 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
169 tm = Map (typeof (object[][]), SomeNamespace);
170 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
174 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
175 public void TestObjectTypeMapping_Array ()
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");
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");
191 public void TestByteTypeMapping ()
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");
201 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
202 public void TestByteTypeMapping_DefaultNamespace ()
204 XmlTypeMapping tm = Map (typeof (byte), SomeNamespace);
205 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
207 tm = Map (typeof (byte[]), SomeNamespace);
208 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
210 tm = Map (typeof (byte[][]), SomeNamespace);
211 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
215 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
216 public void TestByteTypeMapping_Array ()
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");
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");
232 public void TestBoolTypeMapping ()
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");
242 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
243 public void TestBoolTypeMapping_DefaultNamespace ()
245 XmlTypeMapping tm = Map (typeof (bool), "http://somenamespace");
246 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
248 tm = Map (typeof (bool[]), SomeNamespace);
249 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
251 tm = Map (typeof (bool[][]), SomeNamespace);
252 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
256 public void TestShortTypeMapping ()
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");
266 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
267 public void TestShortTypeMapping_DefaultNamespace ()
269 XmlTypeMapping tm = Map (typeof (short), SomeNamespace);
270 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
272 tm = Map (typeof (short[]), SomeNamespace);
273 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
275 tm = Map (typeof (short[][]), SomeNamespace);
276 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
280 public void TestUnsignedShortTypeMapping ()
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");
290 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
291 public void TestUnsignedShortTypeMapping_DefaultNamespace ()
293 XmlTypeMapping tm = Map (typeof (ushort), SomeNamespace);
294 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
296 tm = Map (typeof (ushort[]), SomeNamespace);
297 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
299 tm = Map (typeof (ushort[][]), SomeNamespace);
300 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
304 public void TestUIntTypeMapping ()
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");
314 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
315 public void TestUIntTypeMapping_DefaultNamespace ()
317 XmlTypeMapping tm = Map (typeof (uint), SomeNamespace);
318 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
320 tm = Map (typeof (uint[]), SomeNamespace);
321 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
323 tm = Map (typeof (uint[][]), SomeNamespace);
324 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
328 public void TestLongTypeMapping ()
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");
338 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
339 public void TestLongTypeMapping_DefaultNamespace ()
341 XmlTypeMapping tm = Map (typeof (long), SomeNamespace);
342 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
344 tm = Map (typeof (long[]), SomeNamespace);
345 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
347 tm = Map (typeof (long[][]), SomeNamespace);
348 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
352 public void TestULongTypeMapping ()
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");
362 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
363 public void TestULongTypeMapping_DefaultNamespace ()
365 XmlTypeMapping tm = Map (typeof (ulong), SomeNamespace);
366 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
368 tm = Map (typeof (ulong[]), SomeNamespace);
369 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
371 tm = Map (typeof (ulong[][]), SomeNamespace);
372 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
376 public void TestFloatTypeMapping ()
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");
386 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
387 public void TestFloatTypeMapping_DefaultNamespace ()
389 XmlTypeMapping tm = Map (typeof (float), SomeNamespace);
390 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
392 tm = Map (typeof (float[]), SomeNamespace);
393 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
395 tm = Map (typeof (float[][]), SomeNamespace);
396 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
400 public void TestDoubleTypeMapping ()
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");
410 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
411 public void TestDoubleTypeMapping_DefaultNamespace ()
413 XmlTypeMapping tm = Map (typeof (double), SomeNamespace);
414 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
416 tm = Map (typeof (double[]), SomeNamespace);
417 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
419 tm = Map (typeof (double[][]), SomeNamespace);
420 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
424 public void TestDateTimeTypeMapping ()
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");
434 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
435 public void TestDateTimeTypeMapping_DefaultNamespace ()
437 XmlTypeMapping tm = Map (typeof (DateTime), SomeNamespace);
438 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
440 tm = Map (typeof (DateTime[]), SomeNamespace);
441 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
443 tm = Map (typeof (DateTime[][]), SomeNamespace);
444 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
448 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
449 public void TestDateTimeTypeMapping_Array ()
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");
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");
465 public void TestGuidTypeMapping ()
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");
475 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
476 public void TestGuidTypeMapping_DefaultNamespace ()
478 XmlTypeMapping tm = Map (typeof (Guid), SomeNamespace);
479 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
481 tm = Map (typeof (Guid[]), SomeNamespace);
482 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
484 tm = Map (typeof (Guid[][]), SomeNamespace);
485 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
489 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
490 public void TestGuidTypeMapping_Array ()
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");
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");
506 public void TestDecimalTypeMapping ()
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");
516 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
517 public void TestDecimalTypeMapping_DefaultNamespace ()
519 XmlTypeMapping tm = Map (typeof (decimal), SomeNamespace);
520 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
522 tm = Map (typeof (decimal[]), SomeNamespace);
523 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
525 tm = Map (typeof (decimal[][]), SomeNamespace);
526 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
530 public void TestXmlQualifiedNameTypeMapping ()
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");
540 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
541 public void TestXmlQualifiedNameTypeMapping_DefaultNamespace ()
543 XmlTypeMapping tm = Map (typeof (XmlQualifiedName), SomeNamespace);
544 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
546 tm = Map (typeof (XmlQualifiedName[]), SomeNamespace);
547 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
549 tm = Map (typeof (XmlQualifiedName[][]), SomeNamespace);
550 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
554 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
555 public void TestXmlQualifiedNameTypeMapping_Array ()
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");
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");
571 public void TestSByteTypeMapping ()
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");
581 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
582 public void TestSByteTypeMapping_DefaultNamespace ()
584 XmlTypeMapping tm = Map (typeof (sbyte), SomeNamespace);
585 Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
587 tm = Map (typeof (sbyte[]), SomeNamespace);
588 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
590 tm = Map (typeof (sbyte[][]), SomeNamespace);
591 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
595 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
596 public void TestSByteTypeMapping_Array ()
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");
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");
612 public void TestCharTypeMapping()
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");
622 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
623 public void TestCharTypeMapping_DefaultNamespace ()
625 XmlTypeMapping tm = Map (typeof (char), SomeNamespace);
626 Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
628 tm = Map (typeof (char[]), SomeNamespace);
629 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
631 tm = Map (typeof (char[][]), SomeNamespace);
632 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
636 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
637 public void TestCharTypeMapping_Array ()
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");
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");
653 public void TestXmlNodeTypeMapping ()
656 Map (typeof (XmlNode));
658 } catch (NotSupportedException) {
659 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
663 Map (typeof (XmlNode[]));
665 } catch (NotSupportedException) {
666 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
670 Map (typeof (XmlNode[][]));
672 } catch (NotSupportedException) {
673 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
678 public void TestXmlNodeTypeMapping_DefaultNamespace ()
681 Map (typeof (XmlNode), SomeNamespace);
683 } catch (NotSupportedException) {
684 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
688 Map (typeof (XmlNode[]), SomeNamespace);
690 } catch (NotSupportedException) {
691 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
695 Map (typeof (XmlNode[][]), SomeNamespace);
697 } catch (NotSupportedException) {
698 // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
703 public void TestXmlElementTypeMapping ()
706 Map (typeof (XmlElement));
708 } catch (NotSupportedException) {
709 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
713 Map (typeof (XmlElement[]));
715 } catch (NotSupportedException) {
716 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
720 Map (typeof (XmlElement[][]));
722 } catch (NotSupportedException) {
723 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
728 public void TestXmlElementTypeMapping_DefaultNamespace ()
731 Map (typeof (XmlElement), SomeNamespace);
733 } catch (NotSupportedException) {
734 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
738 Map (typeof (XmlElement[]), SomeNamespace);
740 } catch (NotSupportedException) {
741 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
745 Map (typeof (XmlElement[][]), SomeNamespace);
747 } catch (NotSupportedException) {
748 // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
753 public void TestXmlNotationTypeMapping ()
756 Map (typeof (XmlNotation));
758 } catch (NotSupportedException) {
759 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
763 Map (typeof (XmlNotation[]));
765 } catch (NotSupportedException) {
766 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
770 Map (typeof (XmlNotation[][]));
772 } catch (NotSupportedException) {
773 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
778 public void TestXmlNotationTypeMapping_DefaultNamespace ()
781 Map (typeof (XmlNotation), SomeNamespace);
783 } catch (NotSupportedException) {
784 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
788 Map (typeof (XmlNotation[]), SomeNamespace);
790 } catch (NotSupportedException) {
791 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
795 Map (typeof (XmlNotation[][]), SomeNamespace);
797 } catch (NotSupportedException) {
798 // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
803 [ExpectedException (typeof (NotSupportedException))]
804 public void TestXmlSerializableTypeMapping ()
806 Map (typeof (Employee));
810 [Category ("NotWorking")]
811 [ExpectedException (typeof (NotSupportedException))]
812 public void TestClassTypeMapping_NestedStruct ()
814 Map (typeof (NestedStruct));
818 [ExpectedException (typeof (ArgumentNullException))]
819 public void TestNullTypeMapping()
825 [ExpectedException (typeof (ArgumentNullException))]
826 public void TestNullTypeMapping_DefaultNamespace ()
828 Map (null, SomeNamespace);
832 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
833 public void TestStructTypeMapping ()
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");
843 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
844 public void TestStructTypeMapping_DefaultNamespace ()
846 XmlTypeMapping tm = Map (typeof (TimeSpan), SomeNamespace);
847 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
850 tm = Map (typeof (TimeSpan[]), SomeNamespace);
852 } catch (NotSupportedException) {
856 tm = Map (typeof (TimeSpan[][]), SomeNamespace);
858 } catch (NotSupportedException) {
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 ()
867 Map (typeof (TimeSpan[]));
871 public void TestEnumTypeMapping ()
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");
881 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
882 public void TestEnumTypeMapping_DefaultNamespace ()
884 XmlTypeMapping tm = Map (typeof (AttributeTargets), SomeNamespace);
885 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
887 tm = Map (typeof (AttributeTargets[]), SomeNamespace);
888 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
890 tm = Map (typeof (AttributeTargets[][]), SomeNamespace);
891 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
895 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
896 public void TestEnumTypeMapping_Array ()
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");
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");
912 public void TestClassTypeMapping()
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");
922 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
923 public void TestClassTypeMapping_DefaultNamespace ()
925 XmlTypeMapping tm = Map (typeof (SimpleClass), SomeNamespace);
926 Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
928 tm = Map (typeof (SimpleClass[]), SomeNamespace);
929 Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
931 tm = Map (typeof (SimpleClass[][]), SomeNamespace);
932 Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
936 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
937 public void TestClassTypeMapping_Array ()
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");
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");
954 [Category ("NotDotNet")] // wrong error message is reported in .NET 1.1
956 public void TypeMapping_Attribute_ComplexType ()
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);
964 Map (typeof (Field_Encoded), overrides);
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");
977 public void TypeMapping_Field ()
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");
987 public void TypeMapping_Field_DefaultNamespace ()
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");
997 public void TypeMapping_Field_Encoded ()
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");
1007 public void TypeMapping_Field_Encoded_DefaultNamespace ()
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");
1017 public void TypeMapping_FlagEnum ()
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");
1027 public void TypeMapping_FlagEnum_DefaultNamespace ()
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");
1037 [ExpectedException (typeof (NotSupportedException))]
1038 public void TypeMapping_IDictionary ()
1040 // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer
1041 // is not supported because it implements IDictionary.
1042 Map (typeof (DictionaryWithIndexer));
1046 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1047 public void TypeMapping_IEnumerable_SimpleClass ()
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");
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");
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");
1069 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1070 public void TypeMapping_IEnumerable_Object ()
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");
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");
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");
1092 [ExpectedException (typeof (InvalidOperationException))]
1093 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
1095 Map (typeof (ObjectEnumerableNoMatchingAddMethod));
1099 [ExpectedException (typeof (InvalidOperationException))]
1100 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
1102 Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
1106 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1107 public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
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");
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");
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");
1129 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1131 [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
1133 public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
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");
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");
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");
1155 [ExpectedException (typeof (InvalidOperationException))]
1156 public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
1158 Map (typeof (ObjectCollectionNoMatchingAddMethod));
1162 [ExpectedException (typeof (InvalidOperationException))]
1163 public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
1165 Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
1169 [ExpectedException (typeof (InvalidOperationException))]
1170 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
1172 Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
1176 [ExpectedException (typeof (InvalidOperationException))]
1177 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
1179 Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
1183 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1184 public void TypeMapping_ICollection_SimpleClass ()
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");
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");
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");
1206 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1207 public void TypeMapping_ICollection_Object ()
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");
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");
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");
1229 [ExpectedException (typeof (InvalidOperationException))]
1230 public void TypeMapping_ICollection_Object_NoIntIndexer ()
1232 Map (typeof (ObjectCollectionNoIntIndexer));
1236 [ExpectedException (typeof (InvalidOperationException))]
1237 public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
1239 Map (typeof (ObjectCollectionNoIntIndexer[]));
1243 [ExpectedException (typeof (InvalidOperationException))]
1244 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
1246 Map (typeof (SimpleClassCollectionNoIntIndexer));
1250 [ExpectedException (typeof (InvalidOperationException))]
1251 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
1253 Map (typeof (SimpleClassCollectionNoIntIndexer[]));
1257 public void TypeMapping_InvalidDefault ()
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);
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");
1275 attrs.SoapDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
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");
1288 attrs.SoapDefaultValue = EnumDefaultValueNF.e2; // other enum type
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");
1301 attrs.SoapDefaultValue = (MapModifiers) 20; // non-existing enum value
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");
1316 [Category ("NotWorking")]
1317 public void TestImportMembersMapping()
1319 Type type = typeof (SimpleClass);
1320 SoapAttributes attrs = new SoapAttributes ();
1321 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
1322 overrides.Add (typeof (SimpleClass), attrs);
1324 XmlReflectionMember[] members = new XmlReflectionMember[0];
1325 XmlMembersMapping mm;
1328 mm = MembersMap(type, overrides, members, true, true);
1329 Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
1335 XmlReflectionMember rm = new XmlReflectionMember();
1336 rm.IsReturnValue = false;
1337 rm.MemberName = "something";
1338 rm.MemberType = typeof(string);
1339 members = new XmlReflectionMember[1];
1342 mm = MembersMap(type, overrides, members, false, false);
1344 Equals(mm.Count, 1);
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");
1356 rm = new XmlReflectionMember();
1357 rm.IsReturnValue = false;
1358 rm.MemberName = "nothing";
1359 rm.MemberType = typeof(string);
1360 members = new XmlReflectionMember[1];
1363 mm = MembersMap(type, overrides, members, false, false);
1364 Assert.AreEqual (1 , mm.Count, "#8");
1367 public class Employee : IXmlSerializable
1369 private string _firstName;
1370 private string _lastName;
1371 private string _address;
1373 public XmlSchema GetSchema ()
1378 public void WriteXml (XmlWriter writer)
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 ();
1387 public void ReadXml (XmlReader reader)
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"];
1398 public class NestedStruct
1400 public TimeSpan Period = TimeSpan.MaxValue;
1403 public class ObjectEnumerable : IEnumerable
1405 public void Add (int value)
1409 public void Add (object value)
1413 public IEnumerator GetEnumerator ()
1415 return new ArrayList ().GetEnumerator ();
1419 public class SimpleClassEnumerable : IEnumerable
1421 public void Add (int value)
1425 public void Add (object value)
1429 IEnumerator IEnumerable.GetEnumerator ()
1431 return GetEnumerator ();
1434 public SimpleClassEnumerator GetEnumerator ()
1436 return new SimpleClassEnumerator (new ArrayList ());
1440 public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
1442 public void Add (object value)
1446 IEnumerator IEnumerable.GetEnumerator ()
1448 return new ArrayList ().GetEnumerator ();
1452 public class SimpleClassEnumerablePrivateCurrent : IEnumerable
1454 public void Add (object value)
1458 IEnumerator IEnumerable.GetEnumerator ()
1460 return GetEnumerator ();
1463 public NoCurrentEnumerator GetEnumerator ()
1465 return new NoCurrentEnumerator (new ArrayList ());
1469 // GetEnumerator().Current returns object, but there's no corresponding
1470 // Add (System.Object) method
1471 public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
1473 public void Add (int value)
1477 public IEnumerator GetEnumerator ()
1479 return new ArrayList ().GetEnumerator ();
1483 // GetEnumerator().Current returns SimpleClass, but there's no
1484 // corresponding Add (SimpleClass) method
1485 public class SimpleClassCollectionNoMatchingAddMethod : ICollection
1487 public SimpleClass this[int index] {
1489 return (SimpleClass) _list[index];
1494 get { return _list.Count; }
1497 public bool IsSynchronized {
1498 get { return _list.IsSynchronized; }
1501 public object SyncRoot {
1502 get { return _list.SyncRoot; }
1505 public void CopyTo (Array array, int index)
1507 _list.CopyTo (array, index);
1510 IEnumerator IEnumerable.GetEnumerator()
1512 return GetEnumerator ();
1515 public SimpleClassEnumerator GetEnumerator ()
1517 return new SimpleClassEnumerator (_list);
1520 private ArrayList _list = new ArrayList ();
1523 // GetEnumerator().Current returns object, but there's no corresponding
1524 // Add (System.Object) method
1525 public class ObjectCollectionNoMatchingAddMethod : ICollection
1527 public object this[int index] {
1529 return _list[index];
1534 get { return _list.Count; }
1537 public bool IsSynchronized {
1538 get { return _list.IsSynchronized; }
1541 public object SyncRoot {
1542 get { return _list.SyncRoot; }
1545 public void CopyTo (Array array, int index)
1547 _list.CopyTo (array, index);
1550 IEnumerator IEnumerable.GetEnumerator ()
1552 return GetEnumerator ();
1555 public IEnumerator GetEnumerator ()
1557 return _list.GetEnumerator ();
1560 private ArrayList _list = new ArrayList ();
1563 // Does not have int indexer.
1564 public class SimpleClassCollectionNoIntIndexer : ICollection
1566 public SimpleClass this[string name] {
1568 return new SimpleClass ();
1573 get { return _list.Count; }
1576 public bool IsSynchronized {
1577 get { return _list.IsSynchronized; }
1580 public object SyncRoot {
1581 get { return _list.SyncRoot; }
1584 public void CopyTo (Array array, int index)
1586 _list.CopyTo (array, index);
1589 IEnumerator IEnumerable.GetEnumerator ()
1591 return GetEnumerator ();
1594 public SimpleClassEnumerator GetEnumerator ()
1596 return new SimpleClassEnumerator (_list);
1599 public void Add (SimpleClass value)
1604 private ArrayList _list = new ArrayList ();
1607 // Does not have int indexer.
1608 public class ObjectCollectionNoIntIndexer : ICollection
1610 public object this[string name] {
1612 return new SimpleClass ();
1617 get { return _list.Count; }
1620 public bool IsSynchronized {
1621 get { return _list.IsSynchronized; }
1624 public object SyncRoot {
1625 get { return _list.SyncRoot; }
1628 public void CopyTo (Array array, int index)
1630 _list.CopyTo (array, index);
1633 public IEnumerator GetEnumerator ()
1635 return _list.GetEnumerator ();
1638 public void Add (object value)
1643 private ArrayList _list = new ArrayList ();
1646 public class SimpleClassCollection : ICollection
1648 public SimpleClass this[int index] {
1650 return (SimpleClass) _list[index];
1655 get { return _list.Count; }
1658 public bool IsSynchronized {
1659 get { return _list.IsSynchronized; }
1662 public object SyncRoot {
1663 get { return _list.SyncRoot; }
1666 public void CopyTo (Array array, int index)
1668 _list.CopyTo (array, index);
1671 IEnumerator IEnumerable.GetEnumerator ()
1673 return GetEnumerator ();
1676 public SimpleClassEnumerator GetEnumerator ()
1678 return new SimpleClassEnumerator (_list);
1681 public void Add (SimpleClass value)
1686 private ArrayList _list = new ArrayList ();
1689 public class ObjectCollection : ICollection
1691 public object this[int name] {
1693 return new SimpleClass ();
1699 get { return _list.Count; }
1702 public bool IsSynchronized
1704 get { return _list.IsSynchronized; }
1707 public object SyncRoot
1709 get { return _list.SyncRoot; }
1712 public void CopyTo (Array array, int index)
1714 _list.CopyTo (array, index);
1717 public IEnumerator GetEnumerator ()
1719 return _list.GetEnumerator ();
1722 public void Add (object value)
1727 private ArrayList _list = new ArrayList ();
1730 public class SimpleClassEnumerator : IEnumerator
1732 internal SimpleClassEnumerator (ArrayList arguments)
1734 IEnumerable temp = (IEnumerable) (arguments);
1735 _baseEnumerator = temp.GetEnumerator ();
1737 public SimpleClass Current
1739 get { return (SimpleClass) _baseEnumerator.Current; }
1742 object IEnumerator.Current
1744 get { return _baseEnumerator.Current; }
1747 public bool MoveNext ()
1749 return _baseEnumerator.MoveNext ();
1752 bool IEnumerator.MoveNext ()
1754 return _baseEnumerator.MoveNext ();
1757 public void Reset ()
1759 _baseEnumerator.Reset ();
1762 void IEnumerator.Reset ()
1764 _baseEnumerator.Reset ();
1767 private IEnumerator _baseEnumerator;
1770 public class NoCurrentEnumerator : IEnumerator
1772 internal NoCurrentEnumerator (ArrayList arguments)
1774 IEnumerable temp = (IEnumerable) (arguments);
1775 _baseEnumerator = temp.GetEnumerator ();
1778 object IEnumerator.Current
1780 get { return _baseEnumerator.Current; }
1783 public bool MoveNext ()
1785 return _baseEnumerator.MoveNext ();
1788 bool IEnumerator.MoveNext ()
1790 return _baseEnumerator.MoveNext ();
1793 public void Reset ()
1795 _baseEnumerator.Reset ();
1798 void IEnumerator.Reset ()
1800 _baseEnumerator.Reset ();
1803 private IEnumerator _baseEnumerator;