Parcourir la source

2007-09-25 Atsushi Enomoto <[email protected]>

	* XmlSerializerTests.cs : another XmlSchemaProvider test; use it
	  as a member of an array.


svn path=/trunk/mcs/; revision=86350
Atsushi Eno il y a 18 ans
Parent
commit
ef3263bde5

+ 5 - 0
mcs/class/System.XML/Test/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,8 @@
+2007-09-25  Atsushi Enomoto  <[email protected]>
+
+	* XmlSerializerTests.cs : another XmlSchemaProvider test; use it
+	  as a member of an array.
+
 2007-09-25  Atsushi Enomoto  <[email protected]>
 
 	* XmlSerializerTests.cs : added deserialization test for

+ 24 - 5
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs

@@ -2671,6 +2671,16 @@ namespace MonoTests.System.XmlSerialization
 			Assert.AreEqual (Infoset ("<foo />"), WriterText);
 			xs.Deserialize (new StringReader ("<foo/>"));
 		}
+
+		[Test]
+		public void XmlSchemaProviderQNameBecomesRootName2 ()
+		{
+			string xml = "<XmlSchemaProviderQNameBecomesRootNameType2 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Foo><foo /></Foo></XmlSchemaProviderQNameBecomesRootNameType2>";
+			xs = new XmlSerializer (typeof (XmlSchemaProviderQNameBecomesRootNameType2));
+			Serialize (new XmlSchemaProviderQNameBecomesRootNameType2 ());
+			Assert.AreEqual (Infoset (xml), WriterText);
+			xs.Deserialize (new StringReader (xml));
+		}
 #endif
 
 		#endregion //GenericsSeralizationTests
@@ -2780,6 +2790,7 @@ namespace MonoTests.System.XmlSerialization
 
 			public void ReadXml (XmlReader reader)
 			{
+				reader.Skip ();
 			}
 
 			public void WriteXml (XmlWriter writer)
@@ -2788,14 +2799,22 @@ namespace MonoTests.System.XmlSerialization
 
 			public static XmlQualifiedName GetXsdType (XmlSchemaSet xss)
 			{
-				XmlSchema xs = new XmlSchema ();
-				XmlSchemaComplexType ct = new XmlSchemaComplexType ();
-				ct.Name = "foo";
-				xs.Items.Add (ct);
-				xss.Add (xs);
+				if (xss.Count == 0) {
+					XmlSchema xs = new XmlSchema ();
+					XmlSchemaComplexType ct = new XmlSchemaComplexType ();
+					ct.Name = "foo";
+					xs.Items.Add (ct);
+					xss.Add (xs);
+				}
 				return new XmlQualifiedName ("foo");
 			}
 		}
+
+		public class XmlSchemaProviderQNameBecomesRootNameType2
+		{
+		        [XmlArrayItem (typeof (XmlSchemaProviderQNameBecomesRootNameType))]
+		        public object [] Foo = new object [] {new XmlSchemaProviderQNameBecomesRootNameType ()};
+		}
 #endif
 
 		void CDataTextNodes_BadNode (object s, XmlNodeEventArgs e)