Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2006-03-07 22:25:14 +0300
committerLluis Sanchez <lluis@novell.com>2006-03-07 22:25:14 +0300
commite087a00fc089ddd2bdf7d49f4f44134f7aaad587 (patch)
treef637680480ad8831b9c6f7df1dc0b244e9b64015 /mcs
parent6a75299dccc8f65e2606643df687f171e0b39587 (diff)
2006-03-07 Lluis Sanchez Gual <lluis@novell.com>
* System.Xml.Serialization/XmlSerializerTestClasses.cs: * System.Xml.Serialization/XmlSerializerTests.cs: Added tests for XmlSchemaForm. svn path=/trunk/mcs/; revision=57662
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog6
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs40
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs128
3 files changed, 174 insertions, 0 deletions
diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
index 8ea990a0cf9..a08e8fe0a17 100644
--- a/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
+++ b/mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-07 Lluis Sanchez Gual <lluis@novell.com>
+
+ * System.Xml.Serialization/XmlSerializerTestClasses.cs:
+ * System.Xml.Serialization/XmlSerializerTests.cs: Added tests
+ for XmlSchemaForm.
+
2006-02-16 Gert Driesen <drieseng@users.sourceforge.net>
* XmlReflectionImporter.cs: Enabled few tests for bug #77531.
diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs
index e61d4cfeb7a..40f03970feb 100644
--- a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs
+++ b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs
@@ -522,5 +522,45 @@ namespace MonoTests.System.Xml.TestClasses
public byte[] Password;
public char PathSeparatorCharacter;
}
+
+ public class TestSchemaForm1
+ {
+ public PrintTypeResponse p1;
+
+ [XmlElement(Namespace="urn:oo")]
+ public PrintTypeResponse p2;
+ }
+
+ [XmlType (Namespace="urn:testForm")]
+ public class TestSchemaForm2
+ {
+ public PrintTypeResponse p1;
+
+ [XmlElement(Namespace="urn:oo")]
+ public PrintTypeResponse p2;
+ }
+
+ [XmlType (Namespace="urn:responseTypes")]
+ public class PrintTypeResponse {
+ [XmlElement (Form=XmlSchemaForm.Unqualified, IsNullable=true)]
+ public OutputType result;
+ public PrintTypeResponse intern;
+
+ public void Init ()
+ {
+ result = new OutputType ();
+ result.data = "data1";
+ intern = new PrintTypeResponse ();
+ intern.result = new OutputType ();
+ intern.result.data = "data2";
+ }
+ }
+
+ [XmlType (Namespace="urn:responseTypes")]
+ public class OutputType {
+
+ [XmlElement (Form=XmlSchemaForm.Unqualified, IsNullable=true)]
+ public string data;
+ }
}
diff --git a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs
index 674d8fd2663..7f91220e6b4 100644
--- a/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs
@@ -1363,6 +1363,134 @@ namespace MonoTests.System.XmlSerialization
sw.ToString (), "#2");
}
+ [Test]
+ public void TestSchemaForm ()
+ {
+ TestSchemaForm1 t1 = new TestSchemaForm1 ();
+ t1.p1 = new PrintTypeResponse ();
+ t1.p1.Init ();
+ t1.p2 = new PrintTypeResponse ();
+ t1.p2.Init ();
+
+ TestSchemaForm2 t2 = new TestSchemaForm2 ();
+ t2.p1 = new PrintTypeResponse ();
+ t2.p1.Init ();
+ t2.p2 = new PrintTypeResponse ();
+ t2.p2.Init ();
+
+ Serialize (t1);
+ string res = "";
+ res += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ res += "<TestSchemaForm1 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
+ res += " <p1>";
+ res += " <result>";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p1>";
+ res += " <p2 xmlns=\"urn:oo\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p2>";
+ res += "</TestSchemaForm1>";
+ Assert.AreEqual (Infoset (res), WriterText);
+
+ Serialize (t2);
+ res = "";
+ res += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ res += "<TestSchemaForm2 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
+ res += " <p1 xmlns=\"urn:testForm\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p1>";
+ res += " <p2 xmlns=\"urn:oo\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p2>";
+ res += "</TestSchemaForm2>";
+ Assert.AreEqual (Infoset (res), WriterText);
+
+ XmlReflectionImporter imp = new XmlReflectionImporter ();
+ XmlTypeMapping map = imp.ImportTypeMapping (typeof(TestSchemaForm1), "urn:extra");
+ Serialize (t1, map);
+ res = "";
+ res += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ res += "<TestSchemaForm1 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:extra\">";
+ res += " <p1>";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p1>";
+ res += " <p2 xmlns=\"urn:oo\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p2>";
+ res += "</TestSchemaForm1>";
+ Assert.AreEqual (Infoset (res), WriterText);
+
+ imp = new XmlReflectionImporter ();
+ map = imp.ImportTypeMapping (typeof(TestSchemaForm2), "urn:extra");
+ Serialize (t2, map);
+ res = "";
+ res += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ res += "<TestSchemaForm2 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:extra\">";
+ res += " <p1 xmlns=\"urn:testForm\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p1>";
+ res += " <p2 xmlns=\"urn:oo\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data1</data>";
+ res += " </result>";
+ res += " <intern xmlns=\"urn:responseTypes\">";
+ res += " <result xmlns=\"\">";
+ res += " <data>data2</data>";
+ res += " </result>";
+ res += " </intern>";
+ res += " </p2>";
+ res += "</TestSchemaForm2>";
+ Assert.AreEqual (Infoset (res), WriterText);
+ }
+
// Helper methods
public static string Infoset (string sx)