ソースを参照

2003-12-17 David Sheldon <[email protected]>

  * System.Xml_test.dll.sources : Added XmlSchemaBuiltInDatatypeTests.cs

  * Added XmlSchemaBuiltInDatatypeTests.cs : Currently fails due to
    bug 52274.


  This tests the changes to BuiltInDatatype that I checked in this morning.

svn path=/trunk/mcs/; revision=21288
David Sheldon 22 年 前
コミット
74c080a8ec

+ 4 - 0
mcs/class/System.XML/ChangeLog

@@ -1,3 +1,7 @@
+2003-12-17  David Sheldon <[email protected]>
+
+  * System.Xml_test.dll.sources : Added XmlSchemaBuiltInDatatypeTests.cs
+
 2003-12-15  Atsushi Enomoto  <[email protected]>
 
 	* System.Xml.dll.sources :

+ 1 - 0
mcs/class/System.XML/System.Xml_test.dll.sources

@@ -28,6 +28,7 @@ System.Xml/XsdParticleValidationTests.cs
 System.Xml/XsdValidatingReaderTests.cs
 System.Xml.Schema/XmlSchemaTests.cs
 System.Xml.Schema/XmlSchemaLengthFacetTests.cs
+System.Xml.Schema/XmlSchemaBuiltInDatatypeTests.cs
 System.Xml.Serialization/XmlSerializerTests.cs
 System.Xml.Serialization/XmlSerializerTestClasses.cs
 System.Xml.XPath/SelectNodesTests.cs

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

@@ -1,3 +1,8 @@
+2003-12-17  David Sheldon <[email protected]>
+
+  * Added XmlSchemaBuiltInDatatypeTests.cs : Currently fails due to
+    bug 52274.    
+
 2003-12-14  David Sheldon <[email protected]>
 
   * XmlSchemaLengthFacetTests.cs : Tests for non-integers failing 

+ 80 - 0
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaBuiltInDatatypeTests.cs

@@ -0,0 +1,80 @@
+//
+// Tests for the properties of the builtin types.
+// 
+// Author:
+//   David Sheldon <[email protected]>
+//
+//
+
+using System;
+using System.Xml;
+using System.Xml.Schema;
+using System.IO;
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+	[TestFixture]
+	public class XmlSchemaBuiltInDatatypeTests : Assertion
+	{
+
+    [Test]
+    public void TestWhiteSpaceCollapse () {
+       WhiteSpaceTest("date", "2003-10-10");
+       WhiteSpaceTest("decimal", "2003.10");
+       WhiteSpaceTest("integer", "0004");
+       WhiteSpaceTest("float", "1.3");
+       WhiteSpaceTest("boolean", "true");
+       WhiteSpaceTest("double", "2.3");
+       WhiteSpaceTest("time", "12:34:56");
+       WhiteSpaceTest("duration", "P1347Y");
+       WhiteSpaceTest("dateTime", "2003-10-10Z12:34:56.78");
+       WhiteSpaceTest("gYearMonth", "2003-10");
+       WhiteSpaceTest("gYear", "2003");
+       WhiteSpaceTest("gMonthDay", "--12-12");  // 
+       WhiteSpaceTest("gMonth", "--12--");      //  These three will fail, due to 
+       WhiteSpaceTest("gDay", "---12");         //  bug 52274
+       WhiteSpaceTest("hexBinary", "0fB7");
+    }
+
+
+    /* Takes a type name, and a valid example of that type, 
+       Creates a schema consisting of a single element of that
+       type, and validates a bit of xml containing the valid 
+       value, with whitespace against that schema.
+     
+FIXME: Really we want to test the value of whitespace more
+       directly that by creating a schema then parsing a string.
+     
+     */
+
+    public void WhiteSpaceTest(string type, string valid) {
+      passed = true;
+      XmlSchema schema = new XmlSchema();
+
+      schema.TargetNamespace= "http://example.com/testCase";
+      XmlSchemaElement element = new XmlSchemaElement();
+      element.Name = "a";
+      element.SchemaTypeName = new XmlQualifiedName(type, "http://www.w3.org/2001/XMLSchema");
+      schema.Items.Add(element);
+      schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
+
+      XmlValidatingReader vr = new XmlValidatingReader(new XmlTextReader(new StringReader("<a xmlns='http://example.com/testCase'>\n\n"+valid+"\n\n</a>" )));
+      vr.Schemas.Add(schema);
+      vr.ValidationType = ValidationType.Schema;
+      vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
+      while(vr.Read()) { };
+      vr.Close();
+      
+      Assert(type + " doesn't collapse whitespace", passed);
+    }
+
+    bool passed = true;
+
+    public void ValidationCallbackOne(object sender, ValidationEventArgs args) {
+      passed = false;
+    }
+
+
+  }  
+}