2 // Tests for the properties of the builtin types.
\r
5 // David Sheldon <dave-mono@earth.li>
\r
11 using System.Xml.Schema;
\r
13 using NUnit.Framework;
\r
15 namespace MonoTests.System.Xml
\r
18 public class XmlSchemaBuiltInDatatypeTests
\r
22 public void TestWhiteSpaceCollapse () {
\r
23 WhiteSpaceTest("date", "2003-10-10");
\r
24 WhiteSpaceTest("decimal", "2003.10");
\r
25 WhiteSpaceTest("integer", "0004");
\r
26 WhiteSpaceTest("float", "1.3");
\r
27 WhiteSpaceTest("boolean", "true");
\r
28 WhiteSpaceTest("double", "2.3");
\r
29 WhiteSpaceTest("time", "12:34:56");
\r
30 WhiteSpaceTest("duration", "P1347Y");
\r
31 WhiteSpaceTest("dateTime", "2003-10-10T12:34:56.78");
\r
32 WhiteSpaceTest("gYearMonth", "2003-10");
\r
33 WhiteSpaceTest("gYear", "2003");
\r
34 WhiteSpaceTest("gMonthDay", "--12-12"); //
\r
35 WhiteSpaceTest("gMonth", "--12--"); // These three will fail, due to
\r
36 WhiteSpaceTest("gDay", "---12"); // bug 52274
\r
37 WhiteSpaceTest("hexBinary", "0fB7");
\r
41 /* Takes a type name, and a valid example of that type,
\r
42 Creates a schema consisting of a single element of that
\r
43 type, and validates a bit of xml containing the valid
\r
44 value, with whitespace against that schema.
\r
46 FIXME: Really we want to test the value of whitespace more
\r
47 directly that by creating a schema then parsing a string.
\r
51 public void WhiteSpaceTest(string type, string valid) {
\r
53 XmlSchema schema = new XmlSchema();
\r
55 schema.TargetNamespace= "http://example.com/testCase";
\r
56 XmlSchemaElement element = new XmlSchemaElement();
\r
58 element.SchemaTypeName = new XmlQualifiedName(type, "http://www.w3.org/2001/XMLSchema");
\r
59 schema.Items.Add(element);
\r
60 schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
\r
62 XmlValidatingReader vr = new XmlValidatingReader(new XmlTextReader(new StringReader("<a xmlns='http://example.com/testCase'>\n\n"+valid+"\n\n</a>" )));
\r
63 vr.Schemas.Add(schema);
\r
64 vr.ValidationType = ValidationType.Schema;
\r
65 // vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
\r
66 while(vr.Read()) { };
\r
69 Assert.IsTrue (passed, type + " doesn't collapse whitespace: " + (errorInfo != null ? errorInfo.Message : null));
\r
73 ValidationEventArgs errorInfo;
\r
75 public void ValidationCallbackOne(object sender, ValidationEventArgs args) {
\r