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