Prechádzať zdrojové kódy

2006-01-10 Atsushi Enomoto <[email protected]>

	* System.Xml_test.dll.sources : added XmlSchemaTypeTests.cs.

	* XmlSchemaTypeTests.cs : new file. Test for TypeCode.
	* XmlSchemaSetTests.cs : added more tests for Add() and marked one as
	  NotWorking (we need info on how consistent this method is).


svn path=/trunk/mcs/; revision=55309
Atsushi Eno 20 rokov pred
rodič
commit
3e92836661

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

@@ -1,3 +1,7 @@
+2006-01-10  Atsushi Enomoto  <[email protected]>
+
+	* System.Xml_test.dll.sources : added XmlSchemaTypeTests.cs.
+
 2006-01-10  Atsushi Enomoto  <[email protected]>
 
 	* System.Xml_test.dll.sources : XmlSchemaDatatypeTests.cs was missing.

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

@@ -49,6 +49,7 @@ System.Xml.Schema/XmlSchemaBuiltInDatatypeTests.cs
 System.Xml.Schema/XmlSchemaDatatypeTests.cs
 System.Xml.Schema/XmlSchemaLengthFacetTests.cs
 System.Xml.Schema/XmlSchemaTests.cs
+System.Xml.Schema/XmlSchemaTypeTests.cs
 System.Xml.Schema/XmlSchemaSetTests.cs
 System.Xml.Serialization/ComplexDataStructure.cs
 System.Xml.Serialization/DeserializeTests.cs

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

@@ -1,3 +1,9 @@
+2006-01-10  Atsushi Enomoto <[email protected]>
+
+	* XmlSchemaTypeTests.cs : new file. Test for TypeCode.
+	* XmlSchemaSetTests.cs : added more tests for Add() and marked one as
+	  NotWorking (we need info on how consistent this method is).
+
 2006-01-10  Atsushi Enomoto <[email protected]>
 
 	* XmlSchemaDatatypeTests.cs : oops sys.col.generic is NET_2_0.

+ 25 - 2
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs

@@ -56,9 +56,22 @@ namespace MonoTests.System.Xml
 		}
 
 		[Test]
-		[Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")]
+		public void AddSchemaThenReader ()
+		{
+			XmlSchemaSet ss = new XmlSchemaSet ();
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
+			XmlSchema xs = new XmlSchema ();
+			xs.TargetNamespace = "ab";
+			ss.Add (xs);
+			ss.Add ("ab", new XmlNodeReader (doc));
+		}
+
+		[Test]
+		[Category ("NotWorking")] // How can we differentiate this
+		// case and the testcase above?
 		[ExpectedException (typeof (ArgumentException))]
-		public void AddTwice ()
+		public void AddReaderTwice ()
 		{
 			XmlSchemaSet ss = new XmlSchemaSet ();
 			XmlDocument doc = new XmlDocument ();
@@ -67,6 +80,16 @@ namespace MonoTests.System.Xml
 			ss.Add ("ab", new XmlNodeReader (doc));
 		}
 
+		[Test]
+		public void AddSchemaTwice ()
+		{
+			XmlSchemaSet ss = new XmlSchemaSet ();
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:ab' />");
+			ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
+			ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
+		}
+
 		[Test]
 		public void CompilationSettings ()
 		{

+ 101 - 0
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs

@@ -0,0 +1,101 @@
+//
+// System.Xml.XmlSchemaSetTests.cs
+//
+// Author:
+//	Atsushi Enomoto <[email protected]>
+//
+// (C) 2004 Novell Inc.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using NUnit.Framework;
+
+using QName = System.Xml.XmlQualifiedName;
+using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
+using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
+using AssertType = NUnit.Framework.Assert;
+
+namespace MonoTests.System.Xml
+{
+	[TestFixture]
+	public class XmlSchemaTypeTests
+	{
+#if NET_2_0
+		string [] all_types = new string [] {
+			"string", "boolean", "float", "double", "decimal", 
+			"duration", "dateTime", "time", "date", "gYearMonth", 
+			"gYear", "gMonthDay", "gDay", "gMonth", "hexBinary", 
+			"base64Binary", "anyURI", "QName", "NOTATION", 
+			"normalizedString", "token", "language", "IDREFS",
+			"ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName",
+			"ID", "IDREF", "ENTITY", "integer",
+			"nonPositiveInteger", "negativeInteger", "long",
+			"int", "short", "byte", "nonNegativeInteger",
+			"unsignedLong", "unsignedInt", "unsignedShort",
+			"unsignedByte", "positiveInteger"
+			};
+
+		XmlTypeCode [] type_codes = new XmlTypeCode [] {
+			XmlTypeCode.String,
+			XmlTypeCode.Boolean,
+			XmlTypeCode.Float,
+			XmlTypeCode.Double,
+			XmlTypeCode.Decimal,
+			XmlTypeCode.Duration,
+			XmlTypeCode.DateTime,
+			XmlTypeCode.Time,
+			XmlTypeCode.Date,
+			XmlTypeCode.GYearMonth,
+			XmlTypeCode.GYear,
+			XmlTypeCode.GMonthDay,
+			XmlTypeCode.GDay,
+			XmlTypeCode.GMonth,
+			XmlTypeCode.HexBinary,
+			XmlTypeCode.Base64Binary,
+			XmlTypeCode.AnyUri,
+			XmlTypeCode.QName,
+			XmlTypeCode.Notation,
+			XmlTypeCode.NormalizedString,
+			XmlTypeCode.Token,
+			XmlTypeCode.Language,
+			XmlTypeCode.Idref, // IDREFS (LAMESPEC)
+			XmlTypeCode.Entity, // ENTITIES (LAMESPEC)
+			XmlTypeCode.NmToken,
+			XmlTypeCode.NmToken, // NMTOKENS (LAMESPEC)
+			XmlTypeCode.Name,
+			XmlTypeCode.NCName,
+			XmlTypeCode.Id,
+			XmlTypeCode.Idref,
+			XmlTypeCode.Entity,
+			XmlTypeCode.Integer,
+			XmlTypeCode.NonPositiveInteger,
+			XmlTypeCode.NegativeInteger,
+			XmlTypeCode.Long,
+			XmlTypeCode.Int,
+			XmlTypeCode.Short,
+			XmlTypeCode.Byte,
+			XmlTypeCode.NonNegativeInteger,
+			XmlTypeCode.UnsignedLong,
+			XmlTypeCode.UnsignedInt,
+			XmlTypeCode.UnsignedShort,
+			XmlTypeCode.UnsignedByte,
+			XmlTypeCode.PositiveInteger};
+
+		[Test]
+		public void TypeCode ()
+		{
+			for (int i = 0; i < all_types.Length; i++) {
+				string name = all_types [i];
+				QName qname = new QName (name, XmlSchema.Namespace);
+				Assert.AreEqual (type_codes [i],
+					XmlSchemaType.GetBuiltInSimpleType (qname).TypeCode, name);
+			}
+		}
+
+#endif
+	}
+}