(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.XML / Test / System.Xml.Schema / XmlSchemaDatatypeTests.cs
bloba0d23a0ea613565927b90e16666ebc36fc12de13
1 //
2 // System.Xml.XmlSchemaDatatypeTests.cs
3 //
4 // Author:
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
6 //
7 // (C) 2002 Atsushi Enomoto
8 //
10 using System;
11 using System.IO;
12 using System.Xml;
13 using System.Xml.Schema;
14 using NUnit.Framework;
16 namespace MonoTests.System.Xml
18 [TestFixture]
19 public class XmlSchemaDatatypeTests : Assertion
21 private XmlSchema GetSchema (string path)
23 return XmlSchema.Read (new XmlTextReader (path), null);
26 private XmlQualifiedName QName (string name, string ns)
28 return new XmlQualifiedName (name, ns);
31 private void AssertDatatype (XmlSchema schema, int index,
32 XmlTokenizedType tokenizedType, Type type, string rawValue, object parsedValue)
34 XmlSchemaElement element = schema.Items [index] as XmlSchemaElement;
35 XmlSchemaDatatype dataType = element.ElementType as XmlSchemaDatatype;
36 AssertEquals (tokenizedType, dataType.TokenizedType);
37 AssertEquals (type, dataType.ValueType);
38 AssertEquals (parsedValue, dataType.ParseValue (rawValue, null, null));
41 [Test]
42 public void TestAnyType ()
44 XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd");
45 schema.Compile (null);
46 XmlSchemaElement any = schema.Elements [QName ("e00", "urn:bar")] as XmlSchemaElement;
47 XmlSchemaComplexType cType = any.ElementType as XmlSchemaComplexType;
48 AssertEquals (typeof (XmlSchemaComplexType), cType.GetType ());
49 AssertNotNull (cType);
50 AssertEquals (XmlQualifiedName.Empty, cType.QualifiedName);
51 AssertNull (cType.BaseSchemaType);
52 // In MS.NET its type is "XmlSchemaParticle.EmptyParticle"
53 AssertNotNull (cType.ContentTypeParticle);
56 [Test]
57 public void TestAll ()
59 XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd");
60 schema.Compile (null);
62 AssertDatatype (schema, 1, XmlTokenizedType.CDATA, typeof (string), " f o o ", " f o o ");
63 AssertDatatype (schema, 2, XmlTokenizedType.CDATA, typeof (string), " f o o ", " f o o ");
64 // token shouldn't allow " f o o "
65 AssertDatatype (schema, 3, XmlTokenizedType.CDATA, typeof (string), "f o o", "f o o");
66 // language seems to be checked strictly
67 AssertDatatype (schema, 4, XmlTokenizedType.CDATA, typeof (string), "x-foo", "x-foo");
69 // NMTOKEN shouldn't allow " f o o "
70 // AssertDatatype (schema, 5, XmlTokenizedType.NMTOKEN, typeof (string), "foo", "foo");
71 // AssertDatatype (schema, 6, XmlTokenizedType.NMTOKEN, typeof (string []), "f o o", new string [] {"f", "o", "o"});