Bladeren bron

2005-04-26 Lluis Sanchez Gual <[email protected]>

	* XmlSerializerTests.cs:
	* DeserializeTests.cs:
	* XmlSerializerTestClasses.cs: Added tests for readonly properties and
	elements with spaces on them.


svn path=/trunk/mcs/; revision=43585
Lluis Sanchez 20 jaren geleden
bovenliggende
commit
2bb89efdaf

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

@@ -1,3 +1,10 @@
+2005-04-26  Lluis Sanchez Gual  <[email protected]>
+
+	* XmlSerializerTests.cs:
+	* DeserializeTests.cs:
+	* XmlSerializerTestClasses.cs: Added tests for readonly properties and
+	elements with spaces on them.
+
 2005-03-30  Lluis Sanchez Gual  <[email protected]>
 
 	* XmlSerializerTests.cs:

+ 9 - 1
mcs/class/System.XML/Test/System.Xml.Serialization/DeserializeTests.cs

@@ -192,6 +192,14 @@ namespace MonoTests.System.XmlSerialization
 			ch = (Choices) Deserialize (typeof(Choices), "<Choices><ChoiceTwo>choice text</ChoiceTwo></Choices>");
 			Assertion.AssertEquals ("#1", "choice text", ch.MyChoice);
 			Assertion.AssertEquals ("#2", ItemChoiceType.ChoiceTwo, ch.ItemType);
-		}
+		}
+		
+		[Test]
+		public void TestDeserializeNamesWithSpaces ()
+		{
+			TestSpace ts = (TestSpace) Deserialize (typeof(TestSpace), "<Type_x0020_with_x0020_space xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' Attribute_x0020_with_x0020_space='5'><Element_x0020_with_x0020_space>4</Element_x0020_with_x0020_space></Type_x0020_with_x0020_space>");
+			Assertion.AssertEquals ("#1", 4, ts.elem);
+			Assertion.AssertEquals ("#2", 5, ts.attr);
+		}
 	}
 }

+ 24 - 1
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs

@@ -180,5 +180,28 @@ namespace MonoTests.System.Xml.TestClasses
 
 		[XmlIgnore]
 		public ItemChoiceType ItemType;
-	}
+	}
+	
+	[XmlType ("Type with space")]
+	public class TestSpace
+	{
+	   [XmlElement (ElementName = "Element with space")]
+	   public int elem;
+	    
+	   [XmlAttribute (AttributeName = "Attribute with space")]
+	   public int attr; 
+	}
+
+	[Serializable]
+	public class ReadOnlyProperties {
+		string[] strArr = new string[2] { "string1", "string2" };
+
+		public string[] StrArr {
+			get { return strArr; }
+		}
+		
+		public string dat {
+			get { return "fff"; }
+		} 
+	}
 }

+ 18 - 0
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTests.cs

@@ -716,6 +716,24 @@ namespace MonoTests.System.XmlSerialization
 			AssertEquals(Infoset("<Choices xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><ChoiceTwo>choice text</ChoiceTwo></Choices>"), WriterText);
 		}
 		
+		[Test]
+		public void TestSerializeNamesWithSpaces ()
+		{
+			TestSpace ts = new TestSpace();
+			ts.elem = 4;
+			ts.attr = 5;
+			Serialize (ts);
+			AssertEquals(Infoset("<Type_x0020_with_x0020_space xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' Attribute_x0020_with_x0020_space='5'><Element_x0020_with_x0020_space>4</Element_x0020_with_x0020_space></Type_x0020_with_x0020_space>"), WriterText);
+		}
+		
+		[Test]
+		public void TestSerializeReadOnlyProps ()
+		{
+			ReadOnlyProperties ts = new ReadOnlyProperties();
+			Serialize (ts);
+			AssertEquals(Infoset("<ReadOnlyProperties xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText);
+		}
+		
 		public static string Infoset (string sx)
 		{
 			XmlDocument doc = new XmlDocument ();