SoapReflectionImporterTests.cs, XmlSchemaImporterTests.cs.
* XmlReflectionImporterTests.cs: Added numerous tests. No longer
derive from Assertion.
* SoapReflectionImporterTests.cs: Added numerous tests.
* XmlSchemaImporterTests.cs: Added numerous tests.
* XmlSchemaExporterTests.cs: Added numerous tests.
* SoapSchemaExporterTests.cs: Added numerous tests.
svn path=/trunk/mcs/; revision=55191
+2006-01-07 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * System.Xml_test.dll.sources: Added SoapSchemaExporterTests.cs,
+ SoapReflectionImporterTests.cs, XmlSchemaImporterTests.cs.
+
2005-12-28 Gert Driesen <drieseng@users.sourceforge.net>
* System.Xml_test.dll.sources: Added XmlSchemaExporterTests.cs.
System.Xml.Serialization/SoapElementAttributeTests.cs
System.Xml.Serialization/SoapEnumAttributeTests.cs
System.Xml.Serialization/SoapIncludeAttributeTests.cs
+System.Xml.Serialization/SoapSchemaExporterTests.cs
+System.Xml.Serialization/SoapReflectionImporterTests.cs
System.Xml.Serialization/SoapSchemaMemberTests.cs
System.Xml.Serialization/SoapTypeAttributeTests.cs
System.Xml.Serialization/XmlAnyElementAttributeTests.cs
System.Xml.Serialization/XmlReflectionImporterTests.cs
System.Xml.Serialization/XmlRootAttributeTests.cs
System.Xml.Serialization/XmlSchemaExporterTests.cs
+System.Xml.Serialization/XmlSchemaImporterTests.cs
System.Xml.Serialization/XmlSerializationWriterTests.cs
System.Xml.Serialization/XmlTextAttributeTests.cs
System.Xml.Serialization/XmlTypeAttributeTests.cs
+2006-01-07 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * XmlReflectionImporterTests.cs: Added numerous tests. No longer
+ derive from Assertion.
+ * SoapReflectionImporterTests.cs: Added numerous tests.
+ * XmlSchemaImporterTests.cs: Added numerous tests.
+ * XmlSchemaExporterTests.cs: Added numerous tests.
+ * SoapSchemaExporterTests.cs: Added numerous tests.
+
2005-12-29 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaExporterTests.cs: Added tests for exporting structs, and
--- /dev/null
+//
+// System.Xml.Serialization.SoapReflectionImporterTests
+//
+// Author:
+// Gert Driesen (drieseng@users.sourceforge.net)
+//
+// (C) 2005 Novell
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using NUnit.Framework;
+
+using MonoTests.System.Xml.TestClasses;
+
+namespace MonoTests.System.XmlSerialization
+{
+ [TestFixture]
+ public class SoapReflectionImporterTests
+ {
+ private const string SomeNamespace = "some:urn";
+ private const string AnotherNamespace = "another:urn";
+
+ // these Map methods re-create the SoapReflectionImporter at every call.
+
+ private XmlTypeMapping Map(Type t)
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter();
+ XmlTypeMapping tm = ri.ImportTypeMapping(t);
+
+ return tm;
+ }
+
+ private XmlTypeMapping Map(Type t, string ns)
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter(ns);
+ XmlTypeMapping tm = ri.ImportTypeMapping(t);
+
+ return tm;
+ }
+
+ private XmlTypeMapping Map(Type t, SoapAttributeOverrides overrides)
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter(overrides);
+ XmlTypeMapping tm = ri.ImportTypeMapping(t);
+
+ return tm;
+ }
+
+ private XmlMembersMapping MembersMap (Type t, SoapAttributeOverrides overrides,
+ XmlReflectionMember [] members, bool inContainer, bool writeAccessors)
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter(overrides);
+ XmlMembersMapping mm = ri.ImportMembersMapping(null, null, members,
+ inContainer, writeAccessors);
+
+ return mm;
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestIntTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (int));
+ Assert.AreEqual ("int", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Int32", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestIntTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (int[]));
+ Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (int[][]));
+ Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (int[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfInt", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfInt32", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("Int32[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.Int32[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestStringTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (string));
+ Assert.AreEqual ("string", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("String", tm.TypeName, "#3");
+ Assert.AreEqual ("System.String", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestStringTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (string[]));
+ Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("String[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (string[][]));
+ Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("String[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (string[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("String[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.String[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestObjectTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (object));
+ Assert.AreEqual ("anyType", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Object", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestObjectTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (object[]));
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("Object[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (object[][]));
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (object[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObject", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("Object[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.Object[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestByteTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (byte));
+ Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Byte", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestByteTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (byte[]));
+ Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#A2");
+ Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");
+ Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (byte[][]));
+ Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (byte[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfBase64Binary", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfByte", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("Byte[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.Byte[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestBoolTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (bool));
+ Assert.AreEqual ("boolean", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Boolean", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestShortTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (short));
+ Assert.AreEqual ("short", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Int16", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestUnsignedShortTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (ushort));
+ Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("UInt16", tm.TypeName, "#3");
+ Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestUIntTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (uint));
+ Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("UInt32", tm.TypeName, "#3");
+ Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestLongTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (long));
+ Assert.AreEqual ("long", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Int64", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestULongTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (ulong));
+ Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("UInt64", tm.TypeName, "#3");
+ Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestFloatTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (float));
+ Assert.AreEqual ("float", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Single", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestDoubleTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (double));
+ Assert.AreEqual ("double", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Double", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestDateTimeTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (DateTime));
+ Assert.AreEqual ("dateTime", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("DateTime", tm.TypeName, "#3");
+ Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestDateTimeTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (DateTime[]));
+ Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (DateTime[][]));
+ Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (DateTime[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("DateTime[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.DateTime[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestGuidTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (Guid));
+ Assert.AreEqual ("guid", tm.ElementName, "#1");
+ Assert.AreEqual ("http://microsoft.com/wsdl/types/", tm.Namespace, "#2");
+ Assert.AreEqual ("Guid", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestGuidTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (Guid[]));
+ Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (Guid[][]));
+ Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (Guid[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("Guid[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.Guid[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestDecimalTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (decimal));
+ Assert.AreEqual ("decimal", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Decimal", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestXmlQualifiedNameTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (XmlQualifiedName));
+ Assert.AreEqual ("QName", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestSByteTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (sbyte));
+ Assert.AreEqual ("byte", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("SByte", tm.TypeName, "#3");
+ Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");
+ }
+
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestCharTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (char));
+ Assert.AreEqual ("char", tm.ElementName, "#1");
+ Assert.AreEqual ("http://microsoft.com/wsdl/types/", tm.Namespace, "#2");
+ Assert.AreEqual ("Char", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestCharTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (char[]));
+ Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("Char[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (char[][]));
+ Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (char[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("Char[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.Char[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
+ public void TestXmlNodeTypeMapping ()
+ {
+ Map (typeof (XmlNode));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
+ public void TestXmlElementTypeMapping ()
+ {
+ Map (typeof (XmlElement));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
+ public void TestXmlNotationTypeMapping ()
+ {
+ Map (typeof (XmlNotation));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void TestXmlSerializableTypeMapping ()
+ {
+ Map (typeof (Employee));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void TestClassTypeMapping_NestedStruct ()
+ {
+ Map (typeof (NestedStruct));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TestNullTypeMapping()
+ {
+ Map(null);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestIntTypeMappingWithDefaultNamespaces()
+ {
+ XmlTypeMapping tm = Map (typeof (int), SomeNamespace);
+ Assert.AreEqual ("int", tm.ElementName, "#1");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", tm.Namespace, "#2");
+ Assert.AreEqual ("Int32", tm.TypeName, "#3");
+ Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestStructTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (TimeSpan));
+ Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");
+ Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (NotSupportedException))] // Arrays of structs are not supported with encoded SOAP.
+ public void TestStructTypeMapping_Array ()
+ {
+ Map (typeof (TimeSpan[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestEnumTypeMapping ()
+ {
+ XmlTypeMapping tm = Map (typeof (AttributeTargets));
+ Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");
+ Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestEnumTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (AttributeTargets[]));
+ Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (AttributeTargets[][]));
+ Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (AttributeTargets[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("AttributeTargets[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("System.AttributeTargets[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestClassTypeMapping()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClass));
+ Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestClassTypeMapping_Array ()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClass[]));
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (SimpleClass[][]));
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (SimpleClass[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("SimpleClass[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TypeMapping_IEnumerable_SimpleClass ()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (SimpleClassEnumerable[]));
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (SimpleClassEnumerable[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (SimpleClassEnumerable[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerable[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TypeMapping_IEnumerable_Object ()
+ {
+ XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (ObjectEnumerable[]));
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (ObjectEnumerable[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (ObjectEnumerable[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectEnumerable", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("ObjectEnumerable[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_IEnumarable_Object_NoMatchingAddMethod ()
+ {
+ Map (typeof (ObjectEnumerableNoMatchingAddMethod));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_IEnumarable_Object_NoMatchingAddMethod_Array ()
+ {
+ Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+#if ONLY_1_1
+ [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
+#endif
+ [Category ("NotWorking")]
+ public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
+ {
+ Map (typeof (ObjectCollectionNoMatchingAddMethod));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
+ {
+ Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
+ {
+ Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
+ {
+ Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TypeMapping_ICollection_SimpleClass ()
+ {
+ XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (SimpleClassCollection[]));
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (SimpleClassCollection[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (SimpleClassCollection[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("SimpleClassCollection[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TypeMapping_ICollection_Object ()
+ {
+ XmlTypeMapping tm = Map (typeof (ObjectCollection));
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
+
+ tm = Map (typeof (ObjectCollection[]));
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
+#else
+ Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
+
+ tm = Map (typeof (ObjectCollection[][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
+#else
+ Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
+
+ tm = Map (typeof (ObjectCollection[][][]));
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
+#if NET_2_0
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectCollection", tm.TypeName, "#C3");
+#else
+ Assert.AreEqual ("ObjectCollection[][][]", tm.TypeName, "#C3");
+#endif
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[][][]", tm.TypeFullName, "#C4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_Object_NoIntIndexer ()
+ {
+ Map (typeof (ObjectCollectionNoIntIndexer));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
+ {
+ Map (typeof (ObjectCollectionNoIntIndexer[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
+ {
+ Map (typeof (SimpleClassCollectionNoIntIndexer));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
+ {
+ Map (typeof (SimpleClassCollectionNoIntIndexer[]));
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void TestImportMembersMapping()
+ {
+ Type type = typeof (SimpleClass);
+ SoapAttributes attrs = new SoapAttributes ();
+ SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
+ overrides.Add (typeof (SimpleClass), attrs);
+
+ XmlReflectionMember[] members = new XmlReflectionMember[0];
+ XmlMembersMapping mm;
+ try
+ {
+ mm = MembersMap(type, overrides, members, true, true);
+ Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
+ }
+ catch (Exception)
+ {
+ }
+
+ XmlReflectionMember rm = new XmlReflectionMember();
+ rm.IsReturnValue = false;
+ rm.MemberName = "something";
+ rm.MemberType = typeof(string);
+ members = new XmlReflectionMember[1];
+ members[0] = rm;
+
+ mm = MembersMap(type, overrides, members, false, false);
+
+ Equals(mm.Count, 1);
+
+ XmlMemberMapping smm = mm[0];
+ Assert.IsFalse (smm.Any, "#1");
+ Assert.AreEqual ("something", smm.ElementName, "#2");
+ Assert.AreEqual ("something", smm.MemberName, "#3");
+ Assert.IsNull (smm.Namespace, "#4");
+ Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
+ Assert.AreEqual ("string", smm.TypeName, "#6");
+ Assert.AreEqual ("http://www.w3.org/2001/XMLSchema", smm.TypeNamespace, "#7");
+
+
+ rm = new XmlReflectionMember();
+ rm.IsReturnValue = false;
+ rm.MemberName = "nothing";
+ rm.MemberType = typeof(string);
+ members = new XmlReflectionMember[1];
+ members[0] = rm;
+
+ mm = MembersMap(type, overrides, members, false, false);
+ Assert.AreEqual (1 , mm.Count, "#8");
+ }
+
+ public class Employee : IXmlSerializable
+ {
+ private string _firstName;
+ private string _lastName;
+ private string _address;
+
+ public XmlSchema GetSchema ()
+ {
+ return null;
+ }
+
+ public void WriteXml (XmlWriter writer)
+ {
+ writer.WriteStartElement ("employee", "urn:devx-com");
+ writer.WriteAttributeString ("firstName", _firstName);
+ writer.WriteAttributeString ("lastName", _lastName);
+ writer.WriteAttributeString ("address", _address);
+ writer.WriteEndElement ();
+ }
+
+ public void ReadXml (XmlReader reader)
+ {
+ XmlNodeType type = reader.MoveToContent ();
+ if (type == XmlNodeType.Element && reader.LocalName == "employee") {
+ _firstName = reader["firstName"];
+ _lastName = reader["lastName"];
+ _address = reader["address"];
+ }
+ }
+ }
+
+ public class NestedStruct
+ {
+ public TimeSpan Period = TimeSpan.MaxValue;
+ }
+
+ public class ObjectEnumerable : IEnumerable
+ {
+ public void Add (int value)
+ {
+ }
+
+ public void Add (object value)
+ {
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return new ArrayList ().GetEnumerator ();
+ }
+ }
+
+ public class SimpleClassEnumerable : IEnumerable
+ {
+ public void Add (int value)
+ {
+ }
+
+ public void Add (object value)
+ {
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public SimpleClassEnumerator GetEnumerator ()
+ {
+ return new SimpleClassEnumerator (new ArrayList ());
+ }
+ }
+
+ public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
+ {
+ public void Add (object value)
+ {
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return new ArrayList ().GetEnumerator ();
+ }
+ }
+
+ public class SimpleClassEnumerablePrivateCurrent : IEnumerable
+ {
+ public void Add (object value)
+ {
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public NoCurrentEnumerator GetEnumerator ()
+ {
+ return new NoCurrentEnumerator (new ArrayList ());
+ }
+ }
+
+ // GetEnumerator().Current returns object, but there's no corresponding
+ // Add (System.Object) method
+ public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
+ {
+ public void Add (int value)
+ {
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return new ArrayList ().GetEnumerator ();
+ }
+ }
+
+ // GetEnumerator().Current returns SimpleClass, but there's no
+ // corresponding Add (SimpleClass) method
+ public class SimpleClassCollectionNoMatchingAddMethod : ICollection
+ {
+ public SimpleClass this[int index] {
+ get {
+ return (SimpleClass) _list[index];
+ }
+ }
+
+ public int Count {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator ();
+ }
+
+ public SimpleClassEnumerator GetEnumerator ()
+ {
+ return new SimpleClassEnumerator (_list);
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ // GetEnumerator().Current returns object, but there's no corresponding
+ // Add (System.Object) method
+ public class ObjectCollectionNoMatchingAddMethod : ICollection
+ {
+ public object this[int index] {
+ get {
+ return _list[index];
+ }
+ }
+
+ public int Count {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return _list.GetEnumerator ();
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ // Does not have int indexer.
+ public class SimpleClassCollectionNoIntIndexer : ICollection
+ {
+ public SimpleClass this[string name] {
+ get {
+ return new SimpleClass ();
+ }
+ }
+
+ public int Count {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public SimpleClassEnumerator GetEnumerator ()
+ {
+ return new SimpleClassEnumerator (_list);
+ }
+
+ public void Add (SimpleClass value)
+ {
+ _list.Add (value);
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ // Does not have int indexer.
+ public class ObjectCollectionNoIntIndexer : ICollection
+ {
+ public object this[string name] {
+ get {
+ return new SimpleClass ();
+ }
+ }
+
+ public int Count {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return _list.GetEnumerator ();
+ }
+
+ public void Add (object value)
+ {
+ _list.Add (value);
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ public class SimpleClassCollection : ICollection
+ {
+ public SimpleClass this[int index] {
+ get {
+ return (SimpleClass) _list[index];
+ }
+ }
+
+ public int Count {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public SimpleClassEnumerator GetEnumerator ()
+ {
+ return new SimpleClassEnumerator (_list);
+ }
+
+ public void Add (SimpleClass value)
+ {
+ _list.Add (value);
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ public class ObjectCollection : ICollection
+ {
+ public object this[int name] {
+ get {
+ return new SimpleClass ();
+ }
+ }
+
+ public int Count
+ {
+ get { return _list.Count; }
+ }
+
+ public bool IsSynchronized
+ {
+ get { return _list.IsSynchronized; }
+ }
+
+ public object SyncRoot
+ {
+ get { return _list.SyncRoot; }
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _list.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return _list.GetEnumerator ();
+ }
+
+ public void Add (object value)
+ {
+ _list.Add (value);
+ }
+
+ private ArrayList _list = new ArrayList ();
+ }
+
+ public class SimpleClassEnumerator : IEnumerator
+ {
+ internal SimpleClassEnumerator (ArrayList arguments)
+ {
+ IEnumerable temp = (IEnumerable) (arguments);
+ _baseEnumerator = temp.GetEnumerator ();
+ }
+ public SimpleClass Current
+ {
+ get { return (SimpleClass) _baseEnumerator.Current; }
+ }
+
+ object IEnumerator.Current
+ {
+ get { return _baseEnumerator.Current; }
+ }
+
+ public bool MoveNext ()
+ {
+ return _baseEnumerator.MoveNext ();
+ }
+
+ bool IEnumerator.MoveNext ()
+ {
+ return _baseEnumerator.MoveNext ();
+ }
+
+ public void Reset ()
+ {
+ _baseEnumerator.Reset ();
+ }
+
+ void IEnumerator.Reset ()
+ {
+ _baseEnumerator.Reset ();
+ }
+
+ private IEnumerator _baseEnumerator;
+ }
+
+ public class NoCurrentEnumerator : IEnumerator
+ {
+ internal NoCurrentEnumerator (ArrayList arguments)
+ {
+ IEnumerable temp = (IEnumerable) (arguments);
+ _baseEnumerator = temp.GetEnumerator ();
+ }
+
+ object IEnumerator.Current
+ {
+ get { return _baseEnumerator.Current; }
+ }
+
+ public bool MoveNext ()
+ {
+ return _baseEnumerator.MoveNext ();
+ }
+
+ bool IEnumerator.MoveNext ()
+ {
+ return _baseEnumerator.MoveNext ();
+ }
+
+ public void Reset ()
+ {
+ _baseEnumerator.Reset ();
+ }
+
+ void IEnumerator.Reset ()
+ {
+ _baseEnumerator.Reset ();
+ }
+
+ private IEnumerator _baseEnumerator;
+ }
+ }
+}
--- /dev/null
+//
+// System.Xml.Serialization.SoapSchemaExporterTests
+//
+// Author:
+// Gert Driesen (drieseng@users.sourceforge.net)
+//
+// (C) 2005 Novell
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using NUnit.Framework;
+
+using MonoTests.System.Xml.TestClasses;
+
+namespace MonoTests.System.XmlSerialization
+{
+ [TestFixture]
+ public class SoapSchemaExporterTests
+ {
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportStruct ()
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter ("NSTimeSpan");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (TimeSpan));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"NSTimeSpan\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:complexType name=\"TimeSpan\" />{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportClass ()
+ {
+ SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
+ SoapAttributes attr = new SoapAttributes ();
+ SoapElementAttribute element = new SoapElementAttribute ();
+ element.ElementName = "saying";
+ element.IsNullable = true;
+ attr.SoapElement = element;
+ overrides.Add (typeof (SimpleClass), "something", attr);
+
+ SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClass");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"NSSimpleClass\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:complexType name=\"SimpleClass\">{0}" +
+ " <xs:sequence>{0}" +
+#if NET_2_0
+ " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
+#else
+ " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
+#endif
+ " </xs:sequence>{0}" +
+ " </xs:complexType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
+ public void ExportClass_XmlNode ()
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NS1");
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (XmlNode));
+ sx.ExportTypeMapping (tm);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
+ public void ExportClass_XmlElement ()
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NS1");
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (XmlElement));
+ sx.ExportTypeMapping (tm);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportClass_Array ()
+ {
+ SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
+ SoapAttributes attr = new SoapAttributes ();
+ SoapElementAttribute element = new SoapElementAttribute ();
+ element.ElementName = "saying";
+ element.IsNullable = true;
+ attr.SoapElement = element;
+ overrides.Add (typeof (SimpleClass), "something", attr);
+
+ SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
+ " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
+ " <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
+ " <xs:complexContent mixed=\"false\">{0}" +
+ " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
+ " <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
+ " </xs:restriction>{0}" +
+ " </xs:complexContent>{0}" +
+ " </xs:complexType>{0}" +
+ " <xs:complexType name=\"SimpleClass\">{0}" +
+ " <xs:sequence>{0}" +
+#if NET_2_0
+ " <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
+#else
+ " <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
+#endif
+ " </xs:sequence>{0}" +
+ " </xs:complexType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportEnum ()
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter ("NSEnumDefaultValue");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (EnumDefaultValue));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:simpleType name=\"EnumDefaultValue\">{0}" +
+ " <xs:list>{0}" +
+ " <xs:simpleType>{0}" +
+ " <xs:restriction base=\"xs:string\">{0}" +
+ " <xs:enumeration value=\"e1\" />{0}" +
+ " <xs:enumeration value=\"e2\" />{0}" +
+ " <xs:enumeration value=\"e3\" />{0}" +
+ " </xs:restriction>{0}" +
+ " </xs:simpleType>{0}" +
+ " </xs:list>{0}" +
+ " </xs:simpleType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+
+ ri = new SoapReflectionImporter ("NSEnumDefaultValueNF");
+ schemas = new XmlSchemas ();
+ sx = new SoapSchemaExporter (schemas);
+ tm = ri.ImportTypeMapping (typeof (EnumDefaultValueNF));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#3");
+
+ sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
+ " <xs:restriction base=\"xs:string\">{0}" +
+ " <xs:enumeration value=\"e1\" />{0}" +
+ " <xs:enumeration value=\"e2\" />{0}" +
+ " <xs:enumeration value=\"e3\" />{0}" +
+ " </xs:restriction>{0}" +
+ " </xs:simpleType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportXsdPrimitive ()
+ {
+ ArrayList types = new ArrayList ();
+ types.Add (new TypeDescription (typeof (object), true, "anyType", "Object"));
+ types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
+ types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
+ types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
+ types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
+ types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
+ types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
+ types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
+ types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
+ types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
+ types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
+ types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
+ types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
+ types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
+#if NET_2_0
+ types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
+#else
+ types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName"));
+#endif
+ types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
+
+ foreach (TypeDescription typeDesc in types) {
+ SoapReflectionImporter ri = new SoapReflectionImporter (typeDesc.Type.Name);
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeDesc.Type);
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (0, schemas.Count, typeDesc.Type.FullName + "#1");
+ }
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportXsdPrimitive_ByteArray ()
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter ("ByteArray");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (byte[]));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (0, schemas.Count, "#1");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportXsdPrimitive_Arrays ()
+ {
+ ArrayList types = new ArrayList ();
+ types.Add (new TypeDescription (typeof (object[]), true, "anyType", "AnyType"));
+ types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
+ types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
+ types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
+ types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
+ types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
+ types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
+ types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
+ types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
+ types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
+ types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
+ types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
+ types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
+#if NET_2_0
+ types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
+#else
+ types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
+#endif
+ types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
+
+ foreach (TypeDescription typeDesc in types) {
+ SoapReflectionImporter ri = new SoapReflectionImporter (typeDesc.Type.Name);
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeDesc.Type);
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#else
+ "<xs:schema xmlns:tns=\"{1}\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
+ " <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
+ " <xs:complexType name=\"ArrayOf{2}\">{0}" +
+ " <xs:complexContent mixed=\"false\">{0}" +
+ " <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
+ " <xs:attribute d5p1:arrayType=\"xs:{3}[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
+ " </xs:restriction>{0}" +
+ " </xs:complexContent>{0}" +
+ " </xs:complexType>{0}" +
+ "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType,
+ typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
+ sw.ToString (), typeDesc.Type.FullName + "#2");
+ }
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportNonXsdPrimitive_Guid ()
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter ("NSPrimGuid");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (Guid));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<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}" +
+#else
+ "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:simpleType name=\"guid\">{0}" +
+ " <xs:restriction base=\"xs:string\">{0}" +
+ " <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}" +
+ " </xs:restriction>{0}" +
+ " </xs:simpleType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ExportNonXsdPrimitive_Char ()
+ {
+ SoapReflectionImporter ri = new SoapReflectionImporter ("NSPrimChar");
+ XmlSchemas schemas = new XmlSchemas ();
+ SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (Char));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+#if NET_2_0
+ "<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}" +
+#else
+ "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+#endif
+ " <xs:simpleType name=\"char\">{0}" +
+ " <xs:restriction base=\"xs:unsignedShort\" />{0}" +
+ " </xs:simpleType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
+ public class Employee : IXmlSerializable
+ {
+ private string _firstName;
+ private string _lastName;
+ private string _address;
+
+ public XmlSchema GetSchema ()
+ {
+ return null;
+ }
+
+ public void WriteXml (XmlWriter writer)
+ {
+ writer.WriteStartElement ("employee", "urn:devx-com");
+ writer.WriteAttributeString ("firstName", _firstName);
+ writer.WriteAttributeString ("lastName", _lastName);
+ writer.WriteAttributeString ("address", _address);
+ writer.WriteEndElement ();
+ }
+
+ public void ReadXml (XmlReader reader)
+ {
+ XmlNodeType type = reader.MoveToContent ();
+ if (type == XmlNodeType.Element && reader.LocalName == "employee") {
+ _firstName = reader["firstName"];
+ _lastName = reader["lastName"];
+ _address = reader["address"];
+ }
+ }
+ }
+
+ private class TypeDescription
+ {
+ public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType)
+ : this (type, xsdType, xmlType, arrayType, false)
+ {
+ }
+
+ public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
+ {
+ _type = type;
+ _xsdType = xsdType;
+ _xmlType = xmlType;
+ _arrayType = arrayType;
+ _isNillable = isNillable;
+ }
+
+ public Type Type
+ {
+ get { return _type; }
+ }
+
+ public string XmlType
+ {
+ get { return _xmlType; }
+ }
+
+ public string ArrayType
+ {
+ get { return _arrayType; }
+ }
+
+ public bool XsdType
+ {
+ get { return _xsdType; }
+ }
+
+ public bool IsNillable
+ {
+ get { return _isNillable; }
+ }
+
+ private Type _type;
+ private bool _xsdType;
+ private string _xmlType;
+ private string _arrayType;
+ private bool _isNillable;
+ }
+ }
+}
// \r
\r
using System;\r
+using System.Collections;\r
using System.Xml;\r
+using System.Xml.Schema;\r
using System.Xml.Serialization;\r
\r
using NUnit.Framework;\r
}\r
\r
[TestFixture]\r
- public class XmlReflectionImporterTests : Assertion\r
+ public class XmlReflectionImporterTests\r
{\r
private const string SomeNamespace = "some:urn";\r
private const string AnotherNamespace = "another:urn";\r
return tm;\r
}\r
\r
+ private XmlTypeMapping Map (Type t, string ns, XmlRootAttribute root)\r
+ {\r
+ XmlReflectionImporter ri = new XmlReflectionImporter (ns);\r
+ XmlTypeMapping tm = ri.ImportTypeMapping (t, root);\r
+\r
+ return tm;\r
+ }\r
+\r
private XmlTypeMapping Map(Type t, XmlAttributeOverrides overrides)\r
{\r
XmlReflectionImporter ri = new XmlReflectionImporter(overrides);\r
public void TestIntTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(int));\r
- AssertEquals("int", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Int32", tm.TypeName);\r
- AssertEquals("System.Int32", tm.TypeFullName);\r
+ Assert.AreEqual ("int", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Int32", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
- public void TestIntArrayTypeMapping()\r
+ [Category ("NotWorking")]\r
+ public void TestIntTypeMapping_Array ()\r
{\r
XmlTypeMapping tm = Map(typeof(int[]));\r
- AssertEquals("ArrayOfInt", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Int32[]", tm.TypeName);\r
- AssertEquals("System.Int32[]", tm.TypeFullName);\r
+ Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (int[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (int[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfInt", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfInt32", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Int32[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.Int32[][][]", tm.TypeFullName, "#C4");\r
}\r
\r
[Test]\r
public void TestStringTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(string));\r
- AssertEquals("string", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("String", tm.TypeName);\r
- AssertEquals("System.String", tm.TypeFullName);\r
+ Assert.AreEqual ("string", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("String", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.String", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestStringTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (string[]));\r
+ Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("String[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (string[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("String[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (string[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("String[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.String[][][]", tm.TypeFullName, "#C4");\r
}\r
\r
[Test]\r
public void TestObjectTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(object));\r
- AssertEquals("anyType", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Object", tm.TypeName);\r
- AssertEquals("System.Object", tm.TypeFullName);\r
+ Assert.AreEqual ("anyType", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Object", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestObjectTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (object[]));\r
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("Object[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (object[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (object[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObject", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Object[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.Object[][][]", tm.TypeFullName, "#C4");\r
}\r
\r
[Test]\r
public void TestByteTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(byte));\r
- AssertEquals("unsignedByte", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Byte", tm.TypeName);\r
- AssertEquals("System.Byte", tm.TypeFullName);\r
+ Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Byte", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
- public void TestByteArrayTypeMapping()\r
+ [Category ("NotWorking")]\r
+ public void TestByteTypeMapping_Array ()\r
{\r
XmlTypeMapping tm = Map(typeof(byte[]));\r
- AssertEquals("base64Binary", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Byte[]", tm.TypeName);\r
- AssertEquals("System.Byte[]", tm.TypeFullName);\r
+ Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+ Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");\r
+ Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (byte[][]));\r
+ Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (byte[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfBase64Binary", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfByte", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Byte[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.Byte[][][]", tm.TypeFullName, "#C4");\r
}\r
\r
[Test]\r
public void TestBoolTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(bool));\r
- AssertEquals("boolean", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Boolean", tm.TypeName);\r
- AssertEquals("System.Boolean", tm.TypeFullName);\r
+ Assert.AreEqual ("boolean", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Boolean", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestShortTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(short));\r
- AssertEquals("short", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Int16", tm.TypeName);\r
- AssertEquals("System.Int16", tm.TypeFullName);\r
+ Assert.AreEqual ("short", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Int16", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestUnsignedShortTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(ushort));\r
- AssertEquals("unsignedShort", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("UInt16", tm.TypeName);\r
- AssertEquals("System.UInt16", tm.TypeFullName);\r
+ Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("UInt16", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestUIntTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(uint));\r
- AssertEquals("unsignedInt", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("UInt32", tm.TypeName);\r
- AssertEquals("System.UInt32", tm.TypeFullName);\r
+ Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("UInt32", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestLongTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(long));\r
- AssertEquals("long", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Int64", tm.TypeName);\r
- AssertEquals("System.Int64", tm.TypeFullName);\r
+ Assert.AreEqual ("long", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Int64", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestULongTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(ulong));\r
- AssertEquals("unsignedLong", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("UInt64", tm.TypeName);\r
- AssertEquals("System.UInt64", tm.TypeFullName);\r
+ Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("UInt64", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestFloatTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(float));\r
- AssertEquals("float", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Single", tm.TypeName);\r
- AssertEquals("System.Single", tm.TypeFullName);\r
+ Assert.AreEqual ("float", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Single", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestDoubleTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(double));\r
- AssertEquals("double", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Double", tm.TypeName);\r
- AssertEquals("System.Double", tm.TypeFullName);\r
+ Assert.AreEqual ("double", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Double", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestDateTimeTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(DateTime));\r
- AssertEquals("dateTime", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("DateTime", tm.TypeName);\r
- AssertEquals("System.DateTime", tm.TypeFullName);\r
+ Assert.AreEqual ("dateTime", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("DateTime", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");\r
}\r
- \r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestDateTimeTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (DateTime[]));\r
+ Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (DateTime[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (DateTime[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("DateTime[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.DateTime[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
[Test]\r
public void TestGuidTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(Guid));\r
- AssertEquals("guid", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Guid", tm.TypeName);\r
- AssertEquals("System.Guid", tm.TypeFullName);\r
+ Assert.AreEqual ("guid", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Guid", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");\r
}\r
- \r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestGuidTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (Guid[]));\r
+ Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (Guid[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (Guid[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Guid[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.Guid[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
[Test]\r
public void TestDecimalTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(decimal));\r
- AssertEquals("decimal", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Decimal", tm.TypeName);\r
- AssertEquals("System.Decimal", tm.TypeFullName);\r
+ Assert.AreEqual ("decimal", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Decimal", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestXmlQualifiedNameTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(XmlQualifiedName));\r
- AssertEquals("QName", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("XmlQualifiedName", tm.TypeName);\r
- AssertEquals("System.Xml.XmlQualifiedName", tm.TypeFullName);\r
+ Assert.AreEqual ("QName", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
public void TestSByteTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(sbyte));\r
- AssertEquals("byte", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("SByte", tm.TypeName);\r
- AssertEquals("System.SByte", tm.TypeFullName);\r
+ Assert.AreEqual ("byte", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SByte", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");\r
}\r
\r
\r
public void TestCharTypeMapping()\r
{\r
XmlTypeMapping tm = Map(typeof(char));\r
- AssertEquals("char", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("Char", tm.TypeName);\r
- AssertEquals("System.Char", tm.TypeFullName);\r
+ Assert.AreEqual ("char", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Char", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
- public void TestNullTypeMapping()\r
+ [Category ("NotWorking")]\r
+ public void TestCharTypeMapping_Array ()\r
{\r
- try\r
- {\r
- XmlTypeMapping tm = Map(null);\r
- Fail("Should not be able to map a null type");\r
- }\r
- catch (Exception)\r
- {\r
- }\r
+ XmlTypeMapping tm = Map (typeof (char[]));\r
+ Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("Char[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (char[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (char[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Char[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.Char[][][]", tm.TypeFullName, "#C4");\r
}\r
\r
- \r
[Test]\r
- public void TestInvalidClassTypeMapping()\r
+ [Category ("NotWorking")]\r
+ public void TestXmlNodeTypeMapping ()\r
{\r
- try\r
- {\r
- // this can use any class\r
- XmlTypeMapping tm = Map(typeof(SimpleClass));\r
- Fail("Should not be able to this type");\r
- }\r
- catch (Exception)\r
- {\r
- }\r
+ Type type = typeof (XmlNode);\r
+\r
+ XmlTypeMapping tm = Map (type);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#A1");\r
+ Assert.IsNull (tm.Namespace, "#A2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#A3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (type, AnotherNamespace);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#B1");\r
+ Assert.IsNull (tm.Namespace, "#B2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#B3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#B4");\r
+\r
+ XmlRootAttribute root = new XmlRootAttribute ("somename");\r
+ root.Namespace = SomeNamespace;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#C1");\r
+ Assert.IsNull (tm.Namespace, "#C2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#C3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#C4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#D1");\r
+ Assert.IsNull (tm.Namespace, "#D2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#D3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#D4");\r
+\r
+ root.Namespace = null;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#E1");\r
+ Assert.IsNull (tm.Namespace, "#E2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#E3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#E4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#F1");\r
+ Assert.IsNull (tm.Namespace, "#F2");\r
+ Assert.AreEqual ("XmlNode", tm.TypeName, "#F3");\r
+ Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#F4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestXmlElementTypeMapping ()\r
+ {\r
+ Type type = typeof (XmlElement);\r
+\r
+ XmlTypeMapping tm = Map (type);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#1");\r
+ Assert.IsNull (tm.Namespace, "#2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (type, AnotherNamespace);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#B1");\r
+ Assert.IsNull (tm.Namespace, "#B2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#B3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#B4");\r
+\r
+ XmlRootAttribute root = new XmlRootAttribute ("somename");\r
+ root.Namespace = SomeNamespace;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#C1");\r
+ Assert.IsNull (tm.Namespace, "#C2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#C3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#C4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#D1");\r
+ Assert.IsNull (tm.Namespace, "#D2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#D3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#D4");\r
+\r
+ root.Namespace = null;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#E1");\r
+ Assert.IsNull (tm.Namespace, "#E2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#E3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#E4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#F1");\r
+ Assert.IsNull (tm.Namespace, "#F2");\r
+ Assert.AreEqual ("XmlElement", tm.TypeName, "#F3");\r
+ Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#F4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestXmlNotationTypeMapping ()\r
+ {\r
+ Type type = typeof (XmlNotation);\r
+\r
+ XmlTypeMapping tm = Map (type);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#1");\r
+ Assert.IsNull (tm.Namespace, "#2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (type, AnotherNamespace);\r
+ Assert.AreEqual (string.Empty, tm.ElementName, "#B1");\r
+ Assert.IsNull (tm.Namespace, "#B2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#B3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#B4");\r
+\r
+ XmlRootAttribute root = new XmlRootAttribute ("somename");\r
+ root.Namespace = SomeNamespace;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#C1");\r
+ Assert.IsNull (tm.Namespace, "#C2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#C3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#C4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#D1");\r
+ Assert.IsNull (tm.Namespace, "#D2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#D3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#D4");\r
+\r
+ root.Namespace = null;\r
+ tm = Map (type, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#E1");\r
+ Assert.IsNull (tm.Namespace, "#E2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#E3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#E4");\r
+\r
+ tm = Map (type, AnotherNamespace, root);\r
+ Assert.AreEqual ("somename", tm.ElementName, "#F1");\r
+ Assert.IsNull (tm.Namespace, "#F2");\r
+ Assert.AreEqual ("XmlNotation", tm.TypeName, "#F3");\r
+ Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#F4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestXmlSerializableTypeMapping ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (Employee));\r
+ Assert.AreEqual ("Employee", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Employee", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestXmlSerializableTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (Employee[]));\r
+ Assert.AreEqual ("ArrayOfEmployee", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfEmployee", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("Employee[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (Employee[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("Employee[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (Employee[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("Employee[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestClassTypeMapping_NestedStruct ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (NestedStruct));\r
+ Assert.AreEqual ("NestedStruct", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("NestedStruct", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.NestedStruct", tm.TypeFullName, "#4");\r
}\r
\r
- /*\r
[Test]\r
- public void TestTypeMapping()\r
+ [ExpectedException (typeof (ArgumentNullException))]\r
+ public void TestNullTypeMapping()\r
{\r
- XmlTypeMapping tm = Map(typeof());\r
- AssertEquals(tm.ElementName, "");\r
- AssertEquals(tm.Namespace, "");\r
- AssertEquals(tm.TypeName, "");\r
- AssertEquals(tm.TypeFullName, "System.");\r
+ Map(null);\r
}\r
- */\r
- \r
+\r
[Test]\r
public void TestIntTypeMappingWithDefaultNamespaces()\r
{\r
XmlTypeMapping tm = Map(typeof(int), SomeNamespace);\r
- AssertEquals("int", tm.ElementName);\r
- AssertEquals(SomeNamespace, tm.Namespace);\r
- AssertEquals("Int32", tm.TypeName);\r
- AssertEquals("System.Int32", tm.TypeFullName);\r
+ Assert.AreEqual ("int", tm.ElementName, "#1");\r
+ Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Int32", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
- public void TestValidClassTypeMapping()\r
+ [Category ("NotWorking")]\r
+ public void TestStructTypeMapping ()\r
{\r
- Type type = typeof(SimpleClass);\r
- XmlAttributes attrs = new XmlAttributes();\r
- XmlAttributeOverrides overrides = new XmlAttributeOverrides();\r
- overrides.Add(typeof(SimpleClass), attrs);\r
- \r
- XmlTypeMapping tm = Map(type, overrides);\r
- AssertEquals("SimpleClass", tm.ElementName);\r
- AssertEquals("", tm.Namespace);\r
- AssertEquals("SimpleClass", tm.TypeName);\r
- AssertEquals("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName);\r
+ XmlTypeMapping tm = Map (typeof (TimeSpan));\r
+ Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestStructTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (TimeSpan[]));\r
+ Assert.AreEqual ("ArrayOfTimeSpan", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfTimeSpan", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("TimeSpan[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.TimeSpan[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (TimeSpan[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("TimeSpan[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.TimeSpan[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (TimeSpan[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("TimeSpan[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.TimeSpan[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestEnumTypeMapping ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (AttributeTargets));\r
+ Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestEnumTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (AttributeTargets[]));\r
+ Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (AttributeTargets[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (AttributeTargets[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("AttributeTargets[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("System.AttributeTargets[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ public void TestClassTypeMapping()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClass));\r
+ Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TestClassTypeMapping_Array ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClass[]));\r
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (SimpleClass[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (SimpleClass[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("SimpleClass[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_IEnumerable_SimpleClass ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));\r
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerable[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerable[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerable[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerable[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_IEnumerable_Object ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (ObjectEnumerable));\r
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (ObjectEnumerable[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (ObjectEnumerable[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (ObjectEnumerable[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectEnumerable", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("ObjectEnumerable[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_IEnumarable_Object_NoMatchingAddMethod ()\r
+ {\r
+ Map (typeof (ObjectEnumerableNoMatchingAddMethod));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_IEnumarable_Object_NoMatchingAddMethod_Array ()\r
+ {\r
+ Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));\r
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+#if ONLY_1_1\r
+ [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)\r
+#endif\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));\r
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()\r
+ {\r
+ Map (typeof (ObjectCollectionNoMatchingAddMethod));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()\r
+ {\r
+ Map (typeof (ObjectCollectionNoMatchingAddMethod[]));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()\r
+ {\r
+ Map (typeof (SimpleClassCollectionNoMatchingAddMethod));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()\r
+ {\r
+ Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_ICollection_SimpleClass ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (SimpleClassCollection));\r
+ Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (SimpleClassCollection[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (SimpleClassCollection[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (SimpleClassCollection[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("SimpleClassCollection[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ public void TypeMapping_ICollection_Object ()\r
+ {\r
+ XmlTypeMapping tm = Map (typeof (ObjectCollection));\r
+ Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");\r
+ Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");\r
+\r
+ tm = Map (typeof (ObjectCollection[]));\r
+ Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#A2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");\r
+#else\r
+ Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");\r
+\r
+ tm = Map (typeof (ObjectCollection[][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#B2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");\r
+#else\r
+ Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");\r
+\r
+ tm = Map (typeof (ObjectCollection[][][]));\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");\r
+ Assert.AreEqual (string.Empty, tm.Namespace, "#C2");\r
+#if NET_2_0\r
+ Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectCollection", tm.TypeName, "#C3");\r
+#else\r
+ Assert.AreEqual ("ObjectCollection[][][]", tm.TypeName, "#C3");\r
+#endif\r
+ Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][][]", tm.TypeFullName, "#C4");\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_Object_NoIntIndexer ()\r
+ {\r
+ Map (typeof (ObjectCollectionNoIntIndexer));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()\r
+ {\r
+ Map (typeof (ObjectCollectionNoIntIndexer[]));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()\r
+ {\r
+ Map (typeof (SimpleClassCollectionNoIntIndexer));\r
+ }\r
+\r
+ [Test]\r
+ [Category ("NotWorking")]\r
+ [ExpectedException (typeof (InvalidOperationException))]\r
+ public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()\r
+ {\r
+ Map (typeof (SimpleClassCollectionNoIntIndexer[]));\r
}\r
\r
- \r
[Test]\r
[Category ("NotWorking")]\r
public void TestImportMembersMapping()\r
try\r
{\r
mm = MembersMap(type, overrides, members, true);\r
- Fail("Should not be able to fetch an empty XmlMembersMapping");\r
+ Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");\r
}\r
catch (Exception)\r
{\r
Equals(mm.Count, 1);\r
\r
XmlMemberMapping smm = mm[0];\r
- AssertEquals(false, smm.Any);\r
- AssertEquals("something", smm.ElementName);\r
- AssertEquals("something", smm.MemberName);\r
- AssertEquals(null, smm.Namespace);\r
- AssertEquals("System.String", smm.TypeFullName);\r
- AssertEquals("string", smm.TypeName);\r
- AssertEquals(null, smm.TypeNamespace);\r
+ Assert.IsFalse (smm.Any, "#1");\r
+ Assert.AreEqual ("something", smm.ElementName, "#2");\r
+ Assert.AreEqual ("something", smm.MemberName, "#3");\r
+ Assert.IsNull (smm.Namespace, "#4");\r
+ Assert.AreEqual ("System.String", smm.TypeFullName, "#5");\r
+ Assert.AreEqual ("string", smm.TypeName, "#6");\r
+ Assert.IsNull (smm.TypeNamespace, "#7");\r
\r
\r
rm = new XmlReflectionMember();\r
members[0] = rm;\r
\r
mm = MembersMap(type, overrides, members, false);\r
- Equals(mm.Count, 0);\r
+ Assert.AreEqual (1, mm.Count, "#8");\r
}\r
\r
[Test]\r
root.Namespace = TheNamespace;\r
\r
XmlTypeMapping tm = Map(typeof(int), root);\r
- AssertEquals("price", tm.ElementName);\r
- AssertEquals(TheNamespace, tm.Namespace);\r
- AssertEquals("Int32", tm.TypeName);\r
- AssertEquals("System.Int32", tm.TypeFullName);\r
+ Assert.AreEqual ("price", tm.ElementName, "#1");\r
+ Assert.AreEqual (TheNamespace, tm.Namespace, "#2");\r
+ Assert.AreEqual ("Int32", tm.TypeName, "#3");\r
+ Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");\r
}\r
\r
[Test]\r
{\r
new XmlSerializer (typeof(WrongChoices));\r
}\r
+\r
+ public class Employee : IXmlSerializable\r
+ {\r
+ private string _firstName;\r
+ private string _lastName;\r
+ private string _address;\r
+\r
+ public XmlSchema GetSchema ()\r
+ {\r
+ return null;\r
+ }\r
+\r
+ public void WriteXml (XmlWriter writer)\r
+ {\r
+ writer.WriteStartElement ("employee", "urn:devx-com");\r
+ writer.WriteAttributeString ("firstName", _firstName);\r
+ writer.WriteAttributeString ("lastName", _lastName);\r
+ writer.WriteAttributeString ("address", _address);\r
+ writer.WriteEndElement ();\r
+ }\r
+\r
+ public void ReadXml (XmlReader reader)\r
+ {\r
+ XmlNodeType type = reader.MoveToContent ();\r
+ if (type == XmlNodeType.Element && reader.LocalName == "employee") {\r
+ _firstName = reader["firstName"];\r
+ _lastName = reader["lastName"];\r
+ _address = reader["address"];\r
+ }\r
+ }\r
+ }\r
+\r
+ public class NestedStruct\r
+ {\r
+ public TimeSpan Period = TimeSpan.MaxValue;\r
+ }\r
+\r
+ public class ObjectEnumerable : IEnumerable\r
+ {\r
+ public void Add (int value)\r
+ {\r
+ }\r
+\r
+ public void Add (object value)\r
+ {\r
+ }\r
+\r
+ public IEnumerator GetEnumerator ()\r
+ {\r
+ return new ArrayList ().GetEnumerator ();\r
+ }\r
+ }\r
+\r
+ public class SimpleClassEnumerable : IEnumerable\r
+ {\r
+ public void Add (int value)\r
+ {\r
+ }\r
+\r
+ public void Add (object value)\r
+ {\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public SimpleClassEnumerator GetEnumerator ()\r
+ {\r
+ return new SimpleClassEnumerator (new ArrayList ());\r
+ }\r
+ }\r
+\r
+ public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable\r
+ {\r
+ public void Add (object value)\r
+ {\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return new ArrayList ().GetEnumerator ();\r
+ }\r
+ }\r
+\r
+ public class SimpleClassEnumerablePrivateCurrent : IEnumerable\r
+ {\r
+ public void Add (object value)\r
+ {\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public NoCurrentEnumerator GetEnumerator ()\r
+ {\r
+ return new NoCurrentEnumerator (new ArrayList ());\r
+ }\r
+ }\r
+\r
+ // GetEnumerator().Current returns object, but there's no corresponding\r
+ // Add (System.Object) method\r
+ public class ObjectEnumerableNoMatchingAddMethod : IEnumerable\r
+ {\r
+ public void Add (int value)\r
+ {\r
+ }\r
+\r
+ public IEnumerator GetEnumerator ()\r
+ {\r
+ return new ArrayList ().GetEnumerator ();\r
+ }\r
+ }\r
+\r
+ // GetEnumerator().Current returns SimpleClass, but there's no \r
+ // corresponding Add (SimpleClass) method\r
+ public class SimpleClassCollectionNoMatchingAddMethod : ICollection\r
+ {\r
+ public SimpleClass this[int index]\r
+ {\r
+ get\r
+ {\r
+ return (SimpleClass) _list[index];\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public SimpleClassEnumerator GetEnumerator ()\r
+ {\r
+ return new SimpleClassEnumerator (_list);\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ // GetEnumerator().Current returns object, but there's no corresponding\r
+ // Add (System.Object) method\r
+ public class ObjectCollectionNoMatchingAddMethod : ICollection\r
+ {\r
+ public object this[int index]\r
+ {\r
+ get\r
+ {\r
+ return _list[index];\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public IEnumerator GetEnumerator ()\r
+ {\r
+ return _list.GetEnumerator ();\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ // Does not have int indexer.\r
+ public class SimpleClassCollectionNoIntIndexer : ICollection\r
+ {\r
+ public SimpleClass this[string name]\r
+ {\r
+ get\r
+ {\r
+ return new SimpleClass ();\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public SimpleClassEnumerator GetEnumerator ()\r
+ {\r
+ return new SimpleClassEnumerator (_list);\r
+ }\r
+\r
+ public void Add (SimpleClass value)\r
+ {\r
+ _list.Add (value);\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ // Does not have int indexer.\r
+ public class ObjectCollectionNoIntIndexer : ICollection\r
+ {\r
+ public object this[string name]\r
+ {\r
+ get\r
+ {\r
+ return new SimpleClass ();\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ public IEnumerator GetEnumerator ()\r
+ {\r
+ return _list.GetEnumerator ();\r
+ }\r
+\r
+ public void Add (object value)\r
+ {\r
+ _list.Add (value);\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ public class SimpleClassCollection : ICollection\r
+ {\r
+ public SimpleClass this[int index]\r
+ {\r
+ get\r
+ {\r
+ return (SimpleClass) _list[index];\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ IEnumerator IEnumerable.GetEnumerator ()\r
+ {\r
+ return GetEnumerator ();\r
+ }\r
+\r
+ public SimpleClassEnumerator GetEnumerator ()\r
+ {\r
+ return new SimpleClassEnumerator (_list);\r
+ }\r
+\r
+ public void Add (SimpleClass value)\r
+ {\r
+ _list.Add (value);\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ public class ObjectCollection : ICollection\r
+ {\r
+ public object this[int name]\r
+ {\r
+ get\r
+ {\r
+ return new SimpleClass ();\r
+ }\r
+ }\r
+\r
+ public int Count\r
+ {\r
+ get { return _list.Count; }\r
+ }\r
+\r
+ public bool IsSynchronized\r
+ {\r
+ get { return _list.IsSynchronized; }\r
+ }\r
+\r
+ public object SyncRoot\r
+ {\r
+ get { return _list.SyncRoot; }\r
+ }\r
+\r
+ public void CopyTo (Array array, int index)\r
+ {\r
+ _list.CopyTo (array, index);\r
+ }\r
+\r
+ public IEnumerator GetEnumerator ()\r
+ {\r
+ return _list.GetEnumerator ();\r
+ }\r
+\r
+ public void Add (object value)\r
+ {\r
+ _list.Add (value);\r
+ }\r
+\r
+ private ArrayList _list = new ArrayList ();\r
+ }\r
+\r
+ public class SimpleClassEnumerator : IEnumerator\r
+ {\r
+ internal SimpleClassEnumerator (ArrayList arguments)\r
+ {\r
+ IEnumerable temp = (IEnumerable) (arguments);\r
+ _baseEnumerator = temp.GetEnumerator ();\r
+ }\r
+ public SimpleClass Current\r
+ {\r
+ get { return (SimpleClass) _baseEnumerator.Current; }\r
+ }\r
+\r
+ object IEnumerator.Current\r
+ {\r
+ get { return _baseEnumerator.Current; }\r
+ }\r
+\r
+ public bool MoveNext ()\r
+ {\r
+ return _baseEnumerator.MoveNext ();\r
+ }\r
+\r
+ bool IEnumerator.MoveNext ()\r
+ {\r
+ return _baseEnumerator.MoveNext ();\r
+ }\r
+\r
+ public void Reset ()\r
+ {\r
+ _baseEnumerator.Reset ();\r
+ }\r
+\r
+ void IEnumerator.Reset ()\r
+ {\r
+ _baseEnumerator.Reset ();\r
+ }\r
+\r
+ private IEnumerator _baseEnumerator;\r
+ }\r
+\r
+ public class NoCurrentEnumerator : IEnumerator\r
+ {\r
+ internal NoCurrentEnumerator (ArrayList arguments)\r
+ {\r
+ IEnumerable temp = (IEnumerable) (arguments);\r
+ _baseEnumerator = temp.GetEnumerator ();\r
+ }\r
+\r
+ object IEnumerator.Current\r
+ {\r
+ get { return _baseEnumerator.Current; }\r
+ }\r
+\r
+ public bool MoveNext ()\r
+ {\r
+ return _baseEnumerator.MoveNext ();\r
+ }\r
+\r
+ bool IEnumerator.MoveNext ()\r
+ {\r
+ return _baseEnumerator.MoveNext ();\r
+ }\r
+\r
+ public void Reset ()\r
+ {\r
+ _baseEnumerator.Reset ();\r
+ }\r
+\r
+ void IEnumerator.Reset ()\r
+ {\r
+ _baseEnumerator.Reset ();\r
+ }\r
+\r
+ private IEnumerator _baseEnumerator;\r
+ }\r
}\r
}\r
\r
"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
}
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
+ public void ExportClass_XmlElement ()
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NS1");
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (XmlElement));
+ sx.ExportTypeMapping (tm);
+ }
+
[Test]
[Category ("NotWorking")] // on Mono, element is output before type
public void ExportClass_Array ()
[Category ("NotWorking")] // on Mono, element is output before type
public void ExportEnum ()
{
- XmlReflectionImporter ri = new XmlReflectionImporter ("NS2");
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NSEnumDefaultValue");
XmlSchemas schemas = new XmlSchemas ();
XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
XmlTypeMapping tm = ri.ImportTypeMapping (typeof (EnumDefaultValue));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
- "<xs:schema xmlns:tns=\"NS2\" elementFormDefault=\"qualified\" targetNamespace=\"NS2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
" <xs:element name=\"EnumDefaultValue\" type=\"tns:EnumDefaultValue\" />{0}" +
" <xs:simpleType name=\"EnumDefaultValue\">{0}" +
" <xs:list>{0}" +
" </xs:list>{0}" +
" </xs:simpleType>{0}" +
"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+
+ ri = new XmlReflectionImporter ("NSEnumDefaultValueNF");
+ schemas = new XmlSchemas ();
+ sx = new XmlSchemaExporter (schemas);
+ tm = ri.ImportTypeMapping (typeof (EnumDefaultValueNF));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#3");
+
+ sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+ "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+ " <xs:element name=\"EnumDefaultValueNF\" type=\"tns:EnumDefaultValueNF\" />{0}" +
+ " <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
+ " <xs:restriction base=\"xs:string\">{0}" +
+ " <xs:enumeration value=\"e1\" />{0}" +
+ " <xs:enumeration value=\"e2\" />{0}" +
+ " <xs:enumeration value=\"e3\" />{0}" +
+ " </xs:restriction>{0}" +
+ " </xs:simpleType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
}
[Test]
}
}
+ [Test]
+ [Category ("NotWorking")] // bug #77117
+ public void ExportXsdPrimitive_Object ()
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NSAnyType");
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (object));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+ "<xs:schema xmlns:tns=\"NSAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+ " <xs:element name=\"anyType\" nillable=\"true\" />{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
[Test]
[Category ("NotWorking")] // bug #77117
public void ExportXsdPrimitive_ByteArray ()
}
}
+ [Test]
+ [Category ("NotWorking")] // bug #77117
+ public void ExportXsdPrimitive_Object_Arrays ()
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NSArrayOfAnyType");
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (typeof (object[]));
+ sx.ExportTypeMapping (tm);
+
+ Assert.AreEqual (1, schemas.Count, "#1");
+
+ StringWriter sw = new StringWriter ();
+ schemas[0].Write (sw);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+ "<xs:schema xmlns:tns=\"NSArrayOfAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayOfAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+ " <xs:element name=\"ArrayOfAnyType\" nillable=\"true\" type=\"tns:ArrayOfAnyType\" />{0}" +
+ " <xs:complexType name=\"ArrayOfAnyType\">{0}" +
+ " <xs:sequence>{0}" +
+ " <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
+ " </xs:sequence>{0}" +
+ " </xs:complexType>{0}" +
+ "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+ }
+
[Test]
[Category ("NotWorking")] // bug #77117
public void ExportNonXsdPrimitive_Guid ()
--- /dev/null
+//
+// System.Xml.Serialization.XmlSchemaImporterTests
+//
+// Author:
+// Gert Driesen (drieseng@users.sourceforge.net)
+//
+// (C) 2005 Novell
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using NUnit.Framework;
+
+using MonoTests.System.Xml.TestClasses;
+
+namespace MonoTests.System.XmlSerialization
+{
+ [TestFixture]
+ public class XmlSchemaImporterTests
+ {
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_Struct ()
+ {
+ XmlSchemas schemas = ExportType (typeof (TimeSpan));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("TimeSpan", map.ElementName, "#3");
+ Assert.AreEqual ("NSTimeSpan", map.Namespace, "#4");
+ Assert.AreEqual ("TimeSpan", map.TypeFullName, "#5");
+ Assert.AreEqual ("TimeSpan", map.TypeName, "#6");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_XsdPrimitive_AnyType ()
+ {
+ XmlSchemas schemas = ExportType (typeof (object));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("anyType", map.ElementName, "#3");
+ Assert.AreEqual ("NSObject", map.Namespace, "#4");
+ Assert.AreEqual ("System.Object", map.TypeFullName, "#5");
+ Assert.AreEqual ("Object", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Boolean ()
+ {
+ XmlSchemas schemas = ExportType (typeof (bool));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("boolean", map.ElementName, "#3");
+ Assert.AreEqual ("NSBoolean", map.Namespace, "#4");
+ Assert.AreEqual ("System.Boolean", map.TypeFullName, "#5");
+ Assert.AreEqual ("Boolean", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Short ()
+ {
+ XmlSchemas schemas = ExportType (typeof (short));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("short", map.ElementName, "#3");
+ Assert.AreEqual ("NSInt16", map.Namespace, "#4");
+ Assert.AreEqual ("System.Int16", map.TypeFullName, "#5");
+ Assert.AreEqual ("Int16", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_UnsignedShort ()
+ {
+ XmlSchemas schemas = ExportType (typeof (ushort));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("unsignedShort", map.ElementName, "#3");
+ Assert.AreEqual ("NSUInt16", map.Namespace, "#4");
+ Assert.AreEqual ("System.UInt16", map.TypeFullName, "#5");
+ Assert.AreEqual ("UInt16", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Int ()
+ {
+ XmlSchemas schemas = ExportType (typeof (int));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("int", map.ElementName, "#3");
+ Assert.AreEqual ("NSInt32", map.Namespace, "#4");
+ Assert.AreEqual ("System.Int32", map.TypeFullName, "#5");
+ Assert.AreEqual ("Int32", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_UnsignedInt ()
+ {
+ XmlSchemas schemas = ExportType (typeof (uint));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("unsignedInt", map.ElementName, "#3");
+ Assert.AreEqual ("NSUInt32", map.Namespace, "#4");
+ Assert.AreEqual ("System.UInt32", map.TypeFullName, "#5");
+ Assert.AreEqual ("UInt32", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Long ()
+ {
+ XmlSchemas schemas = ExportType (typeof (long));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("long", map.ElementName, "#3");
+ Assert.AreEqual ("NSInt64", map.Namespace, "#4");
+ Assert.AreEqual ("System.Int64", map.TypeFullName, "#5");
+ Assert.AreEqual ("Int64", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_UnsignedLong ()
+ {
+ XmlSchemas schemas = ExportType (typeof (ulong));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("unsignedLong", map.ElementName, "#3");
+ Assert.AreEqual ("NSUInt64", map.Namespace, "#4");
+ Assert.AreEqual ("System.UInt64", map.TypeFullName, "#5");
+ Assert.AreEqual ("UInt64", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Float ()
+ {
+ XmlSchemas schemas = ExportType (typeof (float));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("float", map.ElementName, "#3");
+ Assert.AreEqual ("NSSingle", map.Namespace, "#4");
+ Assert.AreEqual ("System.Single", map.TypeFullName, "#5");
+ Assert.AreEqual ("Single", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Double ()
+ {
+ XmlSchemas schemas = ExportType (typeof (double));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("double", map.ElementName, "#3");
+ Assert.AreEqual ("NSDouble", map.Namespace, "#4");
+ Assert.AreEqual ("System.Double", map.TypeFullName, "#5");
+ Assert.AreEqual ("Double", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_DateTime ()
+ {
+ XmlSchemas schemas = ExportType (typeof (DateTime));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("dateTime", map.ElementName, "#3");
+ Assert.AreEqual ("NSDateTime", map.Namespace, "#4");
+ Assert.AreEqual ("System.DateTime", map.TypeFullName, "#5");
+ Assert.AreEqual ("DateTime", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Decimal ()
+ {
+ XmlSchemas schemas = ExportType (typeof (decimal));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("decimal", map.ElementName, "#3");
+ Assert.AreEqual ("NSDecimal", map.Namespace, "#4");
+ Assert.AreEqual ("System.Decimal", map.TypeFullName, "#5");
+ Assert.AreEqual ("Decimal", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_QName ()
+ {
+ XmlSchemas schemas = ExportType (typeof (XmlQualifiedName));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("QName", map.ElementName, "#3");
+ Assert.AreEqual ("NSXmlQualifiedName", map.Namespace, "#4");
+ Assert.AreEqual ("System.Xml.XmlQualifiedName", map.TypeFullName, "#5");
+ Assert.AreEqual ("XmlQualifiedName", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_String ()
+ {
+ XmlSchemas schemas = ExportType (typeof (string));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("string", map.ElementName, "#3");
+ Assert.AreEqual ("NSString", map.Namespace, "#4");
+ Assert.AreEqual ("System.String", map.TypeFullName, "#5");
+ Assert.AreEqual ("String", map.TypeName, "#6");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_XsdPrimitive_Guid ()
+ {
+ XmlSchemas schemas = ExportType (typeof (Guid));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("int", map.ElementName, "#3");
+ Assert.AreEqual ("NSInt32", map.Namespace, "#4");
+ Assert.AreEqual ("System.Int32", map.TypeFullName, "#5");
+ Assert.AreEqual ("Int32", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_UnsignedByte ()
+ {
+ XmlSchemas schemas = ExportType (typeof (byte));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("unsignedByte", map.ElementName, "#3");
+ Assert.AreEqual ("NSByte", map.Namespace, "#4");
+ Assert.AreEqual ("System.Byte", map.TypeFullName, "#5");
+ Assert.AreEqual ("Byte", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Byte ()
+ {
+ XmlSchemas schemas = ExportType (typeof (sbyte));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("byte", map.ElementName, "#3");
+ Assert.AreEqual ("NSSByte", map.Namespace, "#4");
+ Assert.AreEqual ("System.SByte", map.TypeFullName, "#5");
+ Assert.AreEqual ("SByte", map.TypeName, "#6");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_XsdPrimitive_Char ()
+ {
+ XmlSchemas schemas = ExportType (typeof (char));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("int", map.ElementName, "#3");
+ Assert.AreEqual ("NSChar", map.Namespace, "#4");
+ Assert.AreEqual ("System.Int32", map.TypeFullName, "#5");
+ Assert.AreEqual ("Int32", map.TypeName, "#6");
+ }
+
+ [Test]
+ public void ImportTypeMapping_XsdPrimitive_Base64Binary ()
+ {
+ XmlSchemas schemas = ExportType (typeof (byte[]));
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#2");
+ Assert.AreEqual ("base64Binary", map.ElementName, "#3");
+ Assert.AreEqual ("NSByte[]", map.Namespace, "#4");
+ Assert.AreEqual ("System.Byte[]", map.TypeFullName, "#5");
+ Assert.AreEqual ("Byte[]", map.TypeName, "#6");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_XsdPrimitive_Duration ()
+ {
+ string schemaFragment = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
+ "<xs:schema xmlns:tns=\"NSDuration\" elementFormDefault=\"qualified\" targetNamespace=\"NSDuration\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
+ " <xs:element name=\"duration\" type=\"xs:duration\" />" +
+ "</xs:schema>";
+
+ XmlSchemas schemas = new XmlSchemas ();
+ schemas.Add (XmlSchema.Read (new StringReader (schemaFragment), null));
+
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlQualifiedName qname = (XmlQualifiedName) qnames[0];
+
+ Assert.AreEqual ("duration", qname.Name, "#2");
+ Assert.AreEqual ("NSDuration", qname.Namespace, "#3");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#4");
+ Assert.AreEqual ("duration", map.ElementName, "#5");
+ Assert.AreEqual ("NSDuration", map.Namespace, "#6");
+ Assert.AreEqual ("System.String", map.TypeFullName, "#7");
+ Assert.AreEqual ("String", map.TypeName, "#8");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void ImportTypeMapping_XsdPrimitive_Date ()
+ {
+ string schemaFragment = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
+ "<xs:schema xmlns:tns=\"NSDate\" elementFormDefault=\"qualified\" targetNamespace=\"NSDate\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
+ " <xs:element name=\"date\" type=\"xs:date\" />" +
+ "</xs:schema>";
+
+ XmlSchemas schemas = new XmlSchemas ();
+ schemas.Add (XmlSchema.Read (new StringReader (schemaFragment), null));
+
+ ArrayList qnames = GetXmlQualifiedNames (schemas);
+ Assert.AreEqual (1, qnames.Count, "#1");
+
+ XmlQualifiedName qname = (XmlQualifiedName) qnames[0];
+
+ Assert.AreEqual ("date", qname.Name, "#2");
+ Assert.AreEqual ("NSDate", qname.Namespace, "#3");
+
+ XmlSchemaImporter importer = new XmlSchemaImporter (schemas);
+ XmlTypeMapping map = importer.ImportTypeMapping ((XmlQualifiedName) qnames[0]);
+
+ Assert.IsNotNull (map, "#4");
+ Assert.AreEqual ("date", map.ElementName, "#5");
+ Assert.AreEqual ("NSDate", map.Namespace, "#6");
+ Assert.AreEqual ("System.DateTime", map.TypeFullName, "#7");
+ Assert.AreEqual ("DateTime", map.TypeName, "#8");
+ }
+
+ private static XmlSchemas ExportType (Type type)
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NS" + type.Name);
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (type);
+ sx.ExportTypeMapping (tm);
+ return schemas;
+ }
+
+ private static ArrayList GetXmlQualifiedNames (XmlSchemas schemas)
+ {
+ ArrayList qnames = new ArrayList ();
+
+ foreach (XmlSchema schema in schemas) {
+ if (!schema.IsCompiled) schema.Compile (null);
+ foreach (XmlSchemaObject ob in schema.Items)
+ if (ob is XmlSchemaElement)
+ qnames.Add (((XmlSchemaElement) ob).QualifiedName);
+ }
+
+ return qnames;
+ }
+ }
+}