2 // System.Xml.Serialization.SoapSchemaExporterTests
5 // Gert Driesen (drieseng@users.sourceforge.net)
11 using System.Collections;
12 using System.Globalization;
15 using System.Xml.Schema;
16 using System.Xml.Serialization;
18 using NUnit.Framework;
20 using MonoTests.System.Xml.TestClasses;
22 namespace MonoTests.System.XmlSerialization
25 public class SoapSchemaExporterTests
27 private XmlSchemas Export (Type type)
29 return Export (type, string.Empty);
32 private XmlSchemas Export (Type type, string defaultNamespace)
34 SoapReflectionImporter ri = new SoapReflectionImporter (defaultNamespace);
35 XmlSchemas schemas = new XmlSchemas ();
36 SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
37 XmlTypeMapping tm = ri.ImportTypeMapping (type);
38 sx.ExportTypeMapping (tm);
42 private XmlSchemas Export (Type type, SoapAttributeOverrides overrides)
44 return Export (type, overrides, string.Empty);
47 private XmlSchemas Export (Type type, SoapAttributeOverrides overrides, string defaultNamespace)
49 SoapReflectionImporter ri = new SoapReflectionImporter (overrides, defaultNamespace);
50 XmlSchemas schemas = new XmlSchemas ();
51 SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
52 XmlTypeMapping tm = ri.ImportTypeMapping (type);
53 sx.ExportTypeMapping (tm);
58 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
59 public void ExportStruct ()
61 XmlSchemas schemas = Export (typeof (TimeSpan), "NSTimeSpan");
62 Assert.AreEqual (1, schemas.Count, "#1");
64 StringWriter sw = new StringWriter ();
65 schemas[0].Write (sw);
67 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
68 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
70 "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
72 "<xs:schema xmlns:tns=\"NSTimeSpan\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
74 " <xs:complexType name=\"TimeSpan\" />{0}" +
75 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
77 schemas = Export (typeof (TimeSpan));
78 Assert.AreEqual (1, schemas.Count, "#3");
80 sw = new StringWriter ();
81 schemas[0].Write (sw);
83 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
84 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
86 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
88 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
90 " <xs:complexType name=\"TimeSpan\" />{0}" +
91 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
95 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
98 [Category ("NotWorking")] // minOccurs is 1 on Mono
101 public void ExportClass_SimpleClass ()
103 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
104 SoapAttributes attr = new SoapAttributes ();
105 SoapElementAttribute element = new SoapElementAttribute ();
106 element.ElementName = "saying";
107 element.IsNullable = true;
108 attr.SoapElement = element;
109 overrides.Add (typeof (SimpleClass), "something", attr);
111 XmlSchemas schemas = Export (typeof (SimpleClass), overrides, "NSSimpleClass");
112 Assert.AreEqual (1, schemas.Count, "#1");
114 StringWriter sw = new StringWriter ();
115 schemas[0].Write (sw);
117 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
118 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
120 "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
122 "<xs:schema xmlns:tns=\"NSSimpleClass\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
124 " <xs:complexType name=\"SimpleClass\">{0}" +
125 " <xs:sequence>{0}" +
127 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
129 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
131 " </xs:sequence>{0}" +
132 " </xs:complexType>{0}" +
133 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
137 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
138 public void ExportClass_StringCollection ()
140 XmlSchemas schemas = Export (typeof (StringCollection), "NSStringCollection");
141 Assert.AreEqual (1, schemas.Count, "#1");
143 StringWriter sw = new StringWriter ();
144 schemas[0].Write (sw);
146 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
147 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
149 "<xs:schema xmlns:tns=\"NSStringCollection\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
151 "<xs:schema xmlns:tns=\"NSStringCollection\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
153 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
154 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
155 " <xs:complexType name=\"ArrayOfString\">{0}" +
156 " <xs:complexContent mixed=\"false\">{0}" +
157 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
158 " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
159 " </xs:restriction>{0}" +
160 " </xs:complexContent>{0}" +
161 " </xs:complexType>{0}" +
162 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
166 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
167 public void ExportClass_StringCollectionContainer ()
169 XmlSchemas schemas = Export (typeof (StringCollectionContainer), "NSStringCollectionContainer");
170 Assert.AreEqual (1, schemas.Count, "#1");
172 StringWriter sw = new StringWriter ();
173 schemas[0].Write (sw);
175 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
176 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
178 "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
180 "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
182 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
183 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
184 " <xs:complexType name=\"StringCollectionContainer\">{0}" +
185 " <xs:sequence>{0}" +
187 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
189 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
191 " </xs:sequence>{0}" +
192 " </xs:complexType>{0}" +
193 " <xs:complexType name=\"ArrayOfString\">{0}" +
194 " <xs:complexContent mixed=\"false\">{0}" +
195 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
196 " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
197 " </xs:restriction>{0}" +
198 " </xs:complexContent>{0}" +
199 " </xs:complexType>{0}" +
200 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
204 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
205 public void ExportClass_ArrayContainer ()
207 XmlSchemas schemas = Export (typeof (ArrayContainer), "NSArrayContainer");
208 Assert.AreEqual (1, schemas.Count, "#1");
210 StringWriter sw = new StringWriter ();
211 schemas[0].Write (sw);
213 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
214 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
216 "<xs:schema xmlns:tns=\"NSArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
218 "<xs:schema xmlns:tns=\"NSArrayContainer\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
220 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
221 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
222 " <xs:complexType name=\"ArrayContainer\">{0}" +
223 " <xs:sequence>{0}" +
225 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
227 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
229 " </xs:sequence>{0}" +
230 " </xs:complexType>{0}" +
231 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
232 " <xs:complexContent mixed=\"false\">{0}" +
233 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
234 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
235 " </xs:restriction>{0}" +
236 " </xs:complexContent>{0}" +
237 " </xs:complexType>{0}" +
238 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
242 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
243 public void ExportClass_ClassArrayContainer ()
245 XmlSchemas schemas = Export (typeof (ClassArrayContainer), "NSClassArrayContainer");
246 Assert.AreEqual (1, schemas.Count, "#1");
248 StringWriter sw = new StringWriter ();
249 schemas[0].Write (sw);
251 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
252 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
254 "<xs:schema xmlns:tns=\"NSClassArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
256 "<xs:schema xmlns:tns=\"NSClassArrayContainer\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
258 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
259 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
260 " <xs:complexType name=\"ClassArrayContainer\">{0}" +
261 " <xs:sequence>{0}" +
263 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
265 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
267 " </xs:sequence>{0}" +
268 " </xs:complexType>{0}" +
269 " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
270 " <xs:complexContent mixed=\"false\">{0}" +
271 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
272 " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
273 " </xs:restriction>{0}" +
274 " </xs:complexContent>{0}" +
275 " </xs:complexType>{0}" +
276 " <xs:complexType name=\"SimpleClass\">{0}" +
277 " <xs:sequence>{0}" +
279 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
281 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
283 " </xs:sequence>{0}" +
284 " </xs:complexType>{0}" +
285 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
289 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
290 public void ExportClass_SimpleClassWithXmlAttributes ()
292 XmlSchemas schemas = Export (typeof (SimpleClassWithXmlAttributes), "NSSimpleClassWithXmlAttributes");
293 Assert.AreEqual (1, schemas.Count, "#1");
295 StringWriter sw = new StringWriter ();
296 schemas[0].Write (sw);
298 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
299 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
301 "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
303 "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
305 " <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
306 " <xs:sequence>{0}" +
308 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
310 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
312 " </xs:sequence>{0}" +
313 " </xs:complexType>{0}" +
314 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
318 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
319 public void ExportClass_Field ()
321 XmlSchemas schemas = Export (typeof (Field), "NSField");
322 Assert.AreEqual (1, schemas.Count, "#1");
324 StringWriter sw = new StringWriter ();
325 schemas[0].Write (sw);
327 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
328 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
330 "<xs:schema xmlns:tns=\"NSField\" elementFormDefault=\"qualified\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
332 "<xs:schema xmlns:tns=\"NSField\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
334 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
335 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
336 " <xs:complexType name=\"Field\">{0}" +
337 " <xs:sequence>{0}" +
339 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags1\" type=\"tns:FlagEnum\" />{0}" +
340 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags2\" type=\"tns:FlagEnum\" />{0}" +
341 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags3\" type=\"tns:FlagEnum\" />{0}" +
342 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Flags4\" type=\"tns:FlagEnum\" />{0}" +
343 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers\" type=\"tns:MapModifiers\" />{0}" +
344 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers2\" type=\"tns:MapModifiers\" />{0}" +
345 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers3\" type=\"tns:MapModifiers\" />{0}" +
346 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers4\" type=\"tns:MapModifiers\" />{0}" +
347 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Modifiers5\" type=\"tns:MapModifiers\" />{0}" +
348 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Names\" type=\"tns:ArrayOfString\" />{0}" +
349 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Street\" type=\"xs:string\" />{0}" +
351 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags1\" type=\"tns:FlagEnum\" />{0}" +
352 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags2\" type=\"tns:FlagEnum\" />{0}" +
353 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags3\" type=\"tns:FlagEnum\" />{0}" +
354 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Flags4\" type=\"tns:FlagEnum\" />{0}" +
355 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers\" type=\"tns:MapModifiers\" />{0}" +
356 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers2\" type=\"tns:MapModifiers\" />{0}" +
357 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers3\" type=\"tns:MapModifiers\" />{0}" +
358 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers4\" type=\"tns:MapModifiers\" />{0}" +
359 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Modifiers5\" type=\"tns:MapModifiers\" />{0}" +
360 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Names\" type=\"tns:ArrayOfString\" />{0}" +
361 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Street\" type=\"xs:string\" />{0}" +
363 " </xs:sequence>{0}" +
364 " </xs:complexType>{0}" +
365 " <xs:simpleType name=\"FlagEnum\">{0}" +
367 " <xs:simpleType>{0}" +
368 " <xs:restriction base=\"xs:string\">{0}" +
369 " <xs:enumeration value=\"e1\" />{0}" +
370 " <xs:enumeration value=\"e2\" />{0}" +
371 " <xs:enumeration value=\"e4\" />{0}" +
372 " </xs:restriction>{0}" +
373 " </xs:simpleType>{0}" +
375 " </xs:simpleType>{0}" +
376 " <xs:simpleType name=\"MapModifiers\">{0}" +
378 " <xs:simpleType>{0}" +
379 " <xs:restriction base=\"xs:string\">{0}" +
380 " <xs:enumeration value=\"Public\" />{0}" +
381 " <xs:enumeration value=\"Protected\" />{0}" +
382 " </xs:restriction>{0}" +
383 " </xs:simpleType>{0}" +
385 " </xs:simpleType>{0}" +
386 " <xs:complexType name=\"ArrayOfString\">{0}" +
387 " <xs:complexContent mixed=\"false\">{0}" +
388 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
389 " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
390 " </xs:restriction>{0}" +
391 " </xs:complexContent>{0}" +
392 " </xs:complexType>{0}" +
393 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
397 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
398 public void ExportClass_MyList ()
400 XmlSchemas schemas = Export (typeof (MyList), "NSMyList");
401 Assert.AreEqual (1, schemas.Count, "#1");
403 StringWriter sw = new StringWriter ();
404 schemas[0].Write (sw);
406 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
407 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
409 "<xs:schema xmlns:tns=\"NSMyList\" elementFormDefault=\"qualified\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
411 "<xs:schema xmlns:tns=\"NSMyList\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
413 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
414 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
415 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
416 " <xs:complexContent mixed=\"false\">{0}" +
417 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
418 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
419 " </xs:restriction>{0}" +
420 " </xs:complexContent>{0}" +
421 " </xs:complexType>{0}" +
422 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
426 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
427 public void ExportClass_Container ()
429 XmlSchemas schemas = Export (typeof (Container), "NSContainer");
430 Assert.AreEqual (1, schemas.Count, "#1");
432 StringWriter sw = new StringWriter ();
433 schemas[0].Write (sw);
435 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
436 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
438 "<xs:schema xmlns:tns=\"NSContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
440 "<xs:schema xmlns:tns=\"NSContainer\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
442 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
443 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
444 " <xs:complexType name=\"Container\">{0}" +
445 " <xs:sequence>{0}" +
447 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
449 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
451 " </xs:sequence>{0}" +
452 " </xs:complexType>{0}" +
453 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
454 " <xs:complexContent mixed=\"false\">{0}" +
455 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
456 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
457 " </xs:restriction>{0}" +
458 " </xs:complexContent>{0}" +
459 " </xs:complexType>{0}" +
460 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
464 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
465 public void ExportClass_Container2 ()
467 XmlSchemas schemas = Export (typeof (Container2), "NSContainer2");
468 Assert.AreEqual (1, schemas.Count, "#1");
470 StringWriter sw = new StringWriter ();
471 schemas[0].Write (sw);
473 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
474 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
476 "<xs:schema xmlns:tns=\"NSContainer2\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
478 "<xs:schema xmlns:tns=\"NSContainer2\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
480 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
481 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
482 " <xs:complexType name=\"Container2\">{0}" +
483 " <xs:sequence>{0}" +
485 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
487 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
489 " </xs:sequence>{0}" +
490 " </xs:complexType>{0}" +
491 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
492 " <xs:complexContent mixed=\"false\">{0}" +
493 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
494 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
495 " </xs:restriction>{0}" +
496 " </xs:complexContent>{0}" +
497 " </xs:complexType>{0}" +
498 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
502 [ExpectedException (typeof (NotSupportedException))]
503 public void ExportClass_MyElem ()
505 Export (typeof (MyElem), "NSMyElem");
509 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
510 [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
511 public void ExportClass_CDataContainer ()
513 Export (typeof (CDataContainer), "NSCDataContainer");
517 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
518 [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
519 public void ExportClass_NodeContainer ()
521 Export (typeof (NodeContainer), "NSNodeContainer");
525 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
526 public void ExportClass_Choices ()
528 XmlSchemas schemas = Export (typeof (Choices), "NSChoices");
529 Assert.AreEqual (1, schemas.Count, "#1");
531 StringWriter sw = new StringWriter ();
532 schemas[0].Write (sw);
534 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
535 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
537 "<xs:schema xmlns:tns=\"NSChoices\" elementFormDefault=\"qualified\" targetNamespace=\"NSChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
539 "<xs:schema xmlns:tns=\"NSChoices\" targetNamespace=\"NSChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
541 " <xs:complexType name=\"Choices\">{0}" +
542 " <xs:sequence>{0}" +
544 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
545 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
547 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
548 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
550 " </xs:sequence>{0}" +
551 " </xs:complexType>{0}" +
552 " <xs:simpleType name=\"ItemChoiceType\">{0}" +
553 " <xs:restriction base=\"xs:string\">{0}" +
554 " <xs:enumeration value=\"ChoiceZero\" />{0}" +
555 " <xs:enumeration value=\"StrangeOne\" />{0}" +
556 " <xs:enumeration value=\"ChoiceTwo\" />{0}" +
557 " </xs:restriction>{0}" +
558 " </xs:simpleType>{0}" +
559 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
563 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
564 public void ExportClass_WrongChoices ()
566 XmlSchemas schemas = Export (typeof (WrongChoices), "NSWrongChoices");
567 Assert.AreEqual (1, schemas.Count, "#1");
569 StringWriter sw = new StringWriter ();
570 schemas[0].Write (sw);
572 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
573 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
575 "<xs:schema xmlns:tns=\"NSWrongChoices\" elementFormDefault=\"qualified\" targetNamespace=\"NSWrongChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
577 "<xs:schema xmlns:tns=\"NSWrongChoices\" targetNamespace=\"NSWrongChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
579 " <xs:complexType name=\"WrongChoices\">{0}" +
580 " <xs:sequence>{0}" +
582 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
583 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
585 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"MyChoice\" type=\"xs:string\" />{0}" +
586 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ItemType\" type=\"tns:ItemChoiceType\" />{0}" +
588 " </xs:sequence>{0}" +
589 " </xs:complexType>{0}" +
590 " <xs:simpleType name=\"ItemChoiceType\">{0}" +
591 " <xs:restriction base=\"xs:string\">{0}" +
592 " <xs:enumeration value=\"ChoiceZero\" />{0}" +
593 " <xs:enumeration value=\"StrangeOne\" />{0}" +
594 " <xs:enumeration value=\"ChoiceTwo\" />{0}" +
595 " </xs:restriction>{0}" +
596 " </xs:simpleType>{0}" +
597 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
601 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
602 public void ExportClass_TestSpace ()
604 XmlSchemas schemas = Export (typeof (TestSpace), "NSTestSpace");
605 Assert.AreEqual (1, schemas.Count, "#1");
607 StringWriter sw = new StringWriter ();
608 schemas[0].Write (sw);
610 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
611 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
613 "<xs:schema xmlns:tns=\"NSTestSpace\" elementFormDefault=\"qualified\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
615 "<xs:schema xmlns:tns=\"NSTestSpace\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
617 " <xs:complexType name=\"TestSpace\">{0}" +
618 " <xs:sequence>{0}" +
620 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"elem\" type=\"xs:int\" />{0}" +
622 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"elem\" type=\"xs:int\" />{0}" +
625 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"attr\" type=\"xs:int\" />{0}" +
627 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"attr\" type=\"xs:int\" />{0}" +
629 " </xs:sequence>{0}" +
630 " </xs:complexType>{0}" +
631 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
635 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
636 public void ExportClass_ReadOnlyProperties ()
638 XmlSchemas schemas = Export (typeof (ReadOnlyProperties), "NSReadOnlyProperties");
639 Assert.AreEqual (1, schemas.Count, "#1");
641 StringWriter sw = new StringWriter ();
642 schemas[0].Write (sw);
644 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
645 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
647 "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" elementFormDefault=\"qualified\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
649 "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
651 " <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
652 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
656 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
657 public void ExportClass_ListDefaults ()
659 XmlSchemas schemas = Export (typeof (ListDefaults), "NSListDefaults");
660 Assert.AreEqual (1, schemas.Count, "#1");
662 StringWriter sw = new StringWriter ();
663 schemas[0].Write (sw);
665 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
666 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
668 "<xs:schema xmlns:tns=\"NSListDefaults\" elementFormDefault=\"qualified\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
670 "<xs:schema xmlns:tns=\"NSListDefaults\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
672 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
673 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
674 " <xs:complexType name=\"ListDefaults\">{0}" +
675 " <xs:sequence>{0}" +
677 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
678 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list3\" type=\"tns:ArrayOfAnyType\" />{0}" +
679 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list4\" type=\"tns:ArrayOfString\" />{0}" +
680 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"list5\" type=\"tns:ArrayOfAnyType\" />{0}" +
681 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"ed\" type=\"tns:SimpleClass\" />{0}" +
682 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"str\" type=\"xs:string\" />{0}" +
684 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
685 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list3\" type=\"tns:ArrayOfAnyType\" />{0}" +
686 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list4\" type=\"tns:ArrayOfString\" />{0}" +
687 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"list5\" type=\"tns:ArrayOfAnyType\" />{0}" +
688 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"ed\" type=\"tns:SimpleClass\" />{0}" +
689 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
691 " </xs:sequence>{0}" +
692 " </xs:complexType>{0}" +
693 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
694 " <xs:complexContent mixed=\"false\">{0}" +
695 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
696 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
697 " </xs:restriction>{0}" +
698 " </xs:complexContent>{0}" +
699 " </xs:complexType>{0}" +
700 " <xs:complexType name=\"SimpleClass\">{0}" +
701 " <xs:sequence>{0}" +
703 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"something\" type=\"xs:string\" />{0}" +
705 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
707 " </xs:sequence>{0}" +
708 " </xs:complexType>{0}" +
709 " <xs:complexType name=\"ArrayOfString\">{0}" +
710 " <xs:complexContent mixed=\"false\">{0}" +
711 " <xs:restriction xmlns:q2=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q2:Array\">{0}" +
712 " <xs:attribute d5p1:arrayType=\"xs:string[]\" ref=\"q2:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
713 " </xs:restriction>{0}" +
714 " </xs:complexContent>{0}" +
715 " </xs:complexType>{0}" +
716 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
720 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
721 public void ExportClass_ClsPerson ()
723 XmlSchemas schemas = Export (typeof (clsPerson), "NSClsPerson");
724 Assert.AreEqual (1, schemas.Count, "#1");
726 StringWriter sw = new StringWriter ();
727 schemas[0].Write (sw);
729 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
730 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
732 "<xs:schema xmlns:tns=\"NSClsPerson\" elementFormDefault=\"qualified\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
734 "<xs:schema xmlns:tns=\"NSClsPerson\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
736 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
737 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
738 " <xs:complexType name=\"clsPerson\">{0}" +
739 " <xs:sequence>{0}" +
741 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
743 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
745 " </xs:sequence>{0}" +
746 " </xs:complexType>{0}" +
747 " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
748 " <xs:complexContent mixed=\"false\">{0}" +
749 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
750 " <xs:attribute d5p1:arrayType=\"xs:anyType[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
751 " </xs:restriction>{0}" +
752 " </xs:complexContent>{0}" +
753 " </xs:complexType>{0}" +
754 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
758 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
759 public void ExportClass_ArrayClass ()
761 XmlSchemas schemas = Export (typeof (ArrayClass), "NSArrayClass");
762 Assert.AreEqual (1, schemas.Count, "#1");
764 StringWriter sw = new StringWriter ();
765 schemas[0].Write (sw);
767 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
768 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
770 "<xs:schema xmlns:tns=\"NSArrayClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
772 "<xs:schema xmlns:tns=\"NSArrayClass\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
774 " <xs:complexType name=\"ArrayClass\">{0}" +
775 " <xs:sequence>{0}" +
777 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"names\" type=\"xs:anyType\" />{0}" +
779 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"names\" type=\"xs:anyType\" />{0}" +
781 " </xs:sequence>{0}" +
782 " </xs:complexType>{0}" +
783 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
787 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
788 public void ExportClass_StructContainer ()
790 XmlSchemas schemas = Export (typeof (StructContainer), "NSStructContainer");
791 Assert.AreEqual (1, schemas.Count, "#1");
793 StringWriter sw = new StringWriter ();
794 schemas[0].Write (sw);
796 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
797 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
799 "<xs:schema xmlns:tns=\"NSStructContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
801 "<xs:schema xmlns:tns=\"NSStructContainer\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
803 " <xs:complexType name=\"StructContainer\">{0}" +
804 " <xs:sequence>{0}" +
806 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" form=\"unqualified\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
808 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
810 " </xs:sequence>{0}" +
811 " </xs:complexType>{0}" +
812 " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
814 " <xs:simpleType>{0}" +
815 " <xs:restriction base=\"xs:string\">{0}" +
816 " <xs:enumeration value=\"e1\" />{0}" +
817 " <xs:enumeration value=\"e2\" />{0}" +
818 " <xs:enumeration value=\"e3\" />{0}" +
819 " </xs:restriction>{0}" +
820 " </xs:simpleType>{0}" +
822 " </xs:simpleType>{0}" +
823 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
827 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
830 [Category ("NotWorking")] // minOccurs is 1 on Mono
833 public void ExportClass_SimpleClass_Array ()
835 SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
836 SoapAttributes attr = new SoapAttributes ();
837 SoapElementAttribute element = new SoapElementAttribute ();
838 element.ElementName = "saying";
839 element.IsNullable = true;
840 attr.SoapElement = element;
841 overrides.Add (typeof (SimpleClass), "something", attr);
843 SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
844 XmlSchemas schemas = new XmlSchemas ();
845 SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
846 XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
847 sx.ExportTypeMapping (tm);
849 Assert.AreEqual (1, schemas.Count, "#1");
851 StringWriter sw = new StringWriter ();
852 schemas[0].Write (sw);
854 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
855 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
857 "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
859 "<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
861 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
862 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
863 " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
864 " <xs:complexContent mixed=\"false\">{0}" +
865 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
866 " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
867 " </xs:restriction>{0}" +
868 " </xs:complexContent>{0}" +
869 " </xs:complexType>{0}" +
870 " <xs:complexType name=\"SimpleClass\">{0}" +
871 " <xs:sequence>{0}" +
873 " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
875 " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
877 " </xs:sequence>{0}" +
878 " </xs:complexType>{0}" +
879 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
883 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
884 public void ExportEnum ()
886 XmlSchemas schemas = Export (typeof (EnumDefaultValue), "NSEnumDefaultValue");
887 Assert.AreEqual (1, schemas.Count, "#1");
889 StringWriter sw = new StringWriter ();
890 schemas[0].Write (sw);
892 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
893 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
895 "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
897 "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
899 " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
901 " <xs:simpleType>{0}" +
902 " <xs:restriction base=\"xs:string\">{0}" +
903 " <xs:enumeration value=\"e1\" />{0}" +
904 " <xs:enumeration value=\"e2\" />{0}" +
905 " <xs:enumeration value=\"e3\" />{0}" +
906 " </xs:restriction>{0}" +
907 " </xs:simpleType>{0}" +
909 " </xs:simpleType>{0}" +
910 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
912 schemas = Export (typeof (EnumDefaultValueNF), "NSEnumDefaultValueNF");
913 Assert.AreEqual (1, schemas.Count, "#3");
915 sw = new StringWriter ();
916 schemas[0].Write (sw);
918 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
919 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
921 "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
923 "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
925 " <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
926 " <xs:restriction base=\"xs:string\">{0}" +
927 " <xs:enumeration value=\"e1\" />{0}" +
928 " <xs:enumeration value=\"e2\" />{0}" +
929 " <xs:enumeration value=\"e3\" />{0}" +
930 " </xs:restriction>{0}" +
931 " </xs:simpleType>{0}" +
932 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
936 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
937 public void ExportXsdPrimitive ()
939 ArrayList types = new ArrayList ();
940 types.Add (new TypeDescription (typeof (object), true, "anyType", "Object"));
941 types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
942 types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
943 types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
944 types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
945 types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
946 types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
947 types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
948 types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
949 types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
950 types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
951 types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
952 types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
953 types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
955 types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
957 types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName"));
959 types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
961 foreach (TypeDescription typeDesc in types) {
962 XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
963 Assert.AreEqual (0, schemas.Count, typeDesc.Type.FullName + "#1");
968 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
969 public void ExportXsdPrimitive_ByteArray ()
971 XmlSchemas schemas = Export (typeof (byte[]), "ByteArray");
972 Assert.AreEqual (0, schemas.Count, "#1");
976 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
977 public void ExportXsdPrimitive_Arrays ()
979 ArrayList types = new ArrayList ();
980 types.Add (new TypeDescription (typeof (object[]), true, "anyType", "AnyType"));
981 types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
982 types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
983 types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
984 types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
985 types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
986 types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
987 types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
988 types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
989 types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
990 types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
991 types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
992 types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
994 types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
996 types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
998 types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
1000 foreach (TypeDescription typeDesc in types) {
1001 XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
1002 Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
1004 StringWriter sw = new StringWriter ();
1005 schemas[0].Write (sw);
1007 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1008 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1010 "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1012 "<xs:schema xmlns:tns=\"{1}\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1014 " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
1015 " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
1016 " <xs:complexType name=\"ArrayOf{2}\">{0}" +
1017 " <xs:complexContent mixed=\"false\">{0}" +
1018 " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
1019 " <xs:attribute d5p1:arrayType=\"xs:{3}[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
1020 " </xs:restriction>{0}" +
1021 " </xs:complexContent>{0}" +
1022 " </xs:complexType>{0}" +
1023 "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType,
1024 typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
1025 sw.ToString (), typeDesc.Type.FullName + "#2");
1030 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1031 public void ExportNonXsdPrimitive_Guid ()
1033 XmlSchemas schemas = Export (typeof (Guid), "NSPrimGuid");
1034 Assert.AreEqual (1, schemas.Count, "#1");
1036 StringWriter sw = new StringWriter ();
1037 schemas[0].Write (sw);
1039 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1040 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1042 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1044 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1046 " <xs:simpleType name=\"guid\">{0}" +
1047 " <xs:restriction base=\"xs:string\">{0}" +
1048 " <xs:pattern value=\"[0-9a-fA-F]{{8}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{12}}\" />{0}" +
1049 " </xs:restriction>{0}" +
1050 " </xs:simpleType>{0}" +
1051 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1055 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1056 public void ExportNonXsdPrimitive_Char ()
1058 XmlSchemas schemas = Export (typeof (Char), "NSPrimChar");
1059 Assert.AreEqual (1, schemas.Count, "#1");
1061 StringWriter sw = new StringWriter ();
1062 schemas[0].Write (sw);
1064 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1065 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1067 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1069 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1071 " <xs:simpleType name=\"char\">{0}" +
1072 " <xs:restriction base=\"xs:unsignedShort\" />{0}" +
1073 " </xs:simpleType>{0}" +
1074 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1077 public class Employee : IXmlSerializable
1079 private string _firstName;
1080 private string _lastName;
1081 private string _address;
1083 public XmlSchema GetSchema ()
1088 public void WriteXml (XmlWriter writer)
1090 writer.WriteStartElement ("employee", "urn:devx-com");
1091 writer.WriteAttributeString ("firstName", _firstName);
1092 writer.WriteAttributeString ("lastName", _lastName);
1093 writer.WriteAttributeString ("address", _address);
1094 writer.WriteEndElement ();
1097 public void ReadXml (XmlReader reader)
1099 XmlNodeType type = reader.MoveToContent ();
1100 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
1101 _firstName = reader["firstName"];
1102 _lastName = reader["lastName"];
1103 _address = reader["address"];
1108 public class StructContainer
1110 public EnumDefaultValue Value;
1113 private class TypeDescription
1115 public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType)
1116 : this (type, xsdType, xmlType, arrayType, false)
1120 public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
1125 _arrayType = arrayType;
1126 _isNillable = isNillable;
1131 get { return _type; }
1134 public string XmlType
1136 get { return _xmlType; }
1139 public string ArrayType
1141 get { return _arrayType; }
1146 get { return _xsdType; }
1149 public bool IsNillable
1151 get { return _isNillable; }
1155 private bool _xsdType;
1156 private string _xmlType;
1157 private string _arrayType;
1158 private bool _isNillable;