Просмотр исходного кода

2004-04-19 Atsushi Enomoto <[email protected]>

	* Added missing ChangeLog entry.
	* ConstraintCollectionTest.cs :
	  Ignore some tests that should fail (They also fail under MS.NET).
	* DataSetReadXmlSchemaTest.cs :
	  - Added SingleElementTreatmentDifference() and PrefixedTargetNS().
	  - Modified UnusedComplexTypesInored() to make sure DataSetName is set.
	  - Renamed DataSetElementCannotBeReferenced() to
	    NestedReferenceNotAllowed().
	  - Modified ReadElemAttrPattern() to LocaleOnRootWithoutIsDataSet()
	    to test msdata:Locale.
	* DataSetTest.cs : Due to mcs bug #57200, csc does not allow
	  System.Type.GetType(), so modified them all.

svn path=/trunk/mcs/; revision=25672
Atsushi Eno 22 лет назад
Родитель
Сommit
d2e97ea2dd

+ 19 - 0
mcs/class/System.Data/Test/System.Data/ChangeLog

@@ -1,8 +1,27 @@
+2004-04-19  Atsushi Enomoto <[email protected]>
+
+	* Added missing ChangeLog entry.
+	* ConstraintCollectionTest.cs :
+	  Ignore some tests that should fail (They also fail under MS.NET).
+	* DataSetReadXmlSchemaTest.cs : 
+	  - Added SingleElementTreatmentDifference() and PrefixedTargetNS().
+	  - Modified UnusedComplexTypesInored() to make sure DataSetName is set.
+	  - Renamed DataSetElementCannotBeReferenced() to 
+	    NestedReferenceNotAllowed().
+	  - Modified ReadElemAttrPattern() to LocaleOnRootWithoutIsDataSet() 
+	    to test msdata:Locale.
+	* DataSetTest.cs : Due to mcs bug #57200, csc does not allow 
+	  System.Type.GetType(), so modified them all.
+
 2004-04-16  Atsushi Enomoto <[email protected]>
 
 	* DataSetAssertion.cs : Added AssertDataColumn().
 	* DataSetReadXmlSchemaTest.cs : Added more strange cases.
 
+2004-04-15	Umadevi S ([email protected])
+		* ForeignKeyConstraintTest - constructor testing,
+		* DataSet - test for Clone and Copy methods.
+
 2004-04-15  Atsushi Enomoto <[email protected]>
 
 	* Added DataSetAssertion.cs and DataSetReadXmlSchema.cs.

+ 4 - 1
mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest.cs

@@ -382,6 +382,7 @@ namespace MonoTests.System.Data
 		}
 
 		[Test]
+		[Ignore ("This never works on MS.NET (and it should not)")]
 		public void CanRemove()
 		{
 			AssertEquals ("A1", false, _table.Constraints.CanRemove (_table.Constraints [0]));
@@ -394,6 +395,7 @@ namespace MonoTests.System.Data
 		}
 
 		[Test]
+		[Ignore ("MS.NET fails this test (and it should fail)")]
 		public void RemoveAt()
 		{
 			 _table2.Constraints.RemoveAt (1); //Remove constraint and again add it
@@ -405,6 +407,7 @@ namespace MonoTests.System.Data
 		}
 
 		[Test]
+		[Ignore ("MS.NET fails this test (and it should fail)")]
 		public void Remove()
 		{
 			_table2.Constraints.Remove (_table2.Constraints [1]); //Remove constraint and again add it
@@ -426,7 +429,7 @@ namespace MonoTests.System.Data
                         catch (Exception e) {
                                 if (e.GetType ()!= typeof (AssertionException)) {
                                         AssertEquals ("A2",
-                                                "Cannot remove UniqueConstraint because the ForeignKeyConstraint FK2 exists",e.Message);
+                                                "Cannot remove UniqueConstraint because the ForeignKeyConstraint FK2 exists.",e.Message);
                                 }
                         }
                 }

+ 108 - 9
mcs/class/System.Data/Test/System.Data/DataSetReadXmlSchemaTest.cs

@@ -35,10 +35,51 @@ namespace MonoTests.System.Data
 			return ds;
 		}
 
+		[Test]
+		public void SingleElementTreatmentDifference ()
+		{
+			// This is one of the most complicated case. When the content
+			// type particle of 'Root' element is a complex element, it
+			// is DataSet element. Otherwise, it is just a data table.
+			//
+			// But also note that there is another test named
+			// LocaleOnRootWithoutIsDataSet(), that tests if locale on
+			// the (mere) data table modifies *DataSet's* locale.
+			string xsbase = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
+	<xs:element name='Root'> <!-- becomes table -->
+		<xs:complexType>
+			<xs:choice maxOccurs='unbounded'>
+				{0}
+			</xs:choice>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>";
+			string simple = "<xs:element name='Child' type='xs:string' />";
+			string complex = @"<xs:element name='Child'>
+					<xs:complexType>
+						<xs:attribute name='a1' />
+						<xs:attribute name='a2'/>
+					</xs:complexType>
+				</xs:element>";
+
+			DataSet ds = new DataSet ();
+
+			string xs = String.Format (xsbase, simple);
+			ds.ReadXmlSchema (new StringReader (xs));
+			AssertDataSet ("simple", ds, "hoge", 1);
+			AssertDataTable ("simple", ds.Tables [0], "Root", 1, 0);
+
+			ds = new DataSet ();
+			xs = String.Format (xsbase, complex);
+			ds.ReadXmlSchema (new StringReader (xs));
+			AssertDataSet ("complex", ds, "Root", 1);
+			AssertDataTable ("complex", ds.Tables [0], "Child", 2, 0);
+		}
+
 		[Test]
 		public void UnusedComplexTypesIgnored ()
 		{
-			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
 	<xs:element name='Root'>
 		<xs:complexType>
 			<xs:sequence>
@@ -48,7 +89,7 @@ namespace MonoTests.System.Data
 	</xs:element>
 	<xs:complexType name='unusedType'>
 		<xs:sequence>
-			<xs:element name='Child' type='xs:string' />
+			<xs:element name='Orphan' type='xs:string' />
 		</xs:sequence>
 	</xs:complexType>
 </xs:schema>";
@@ -56,7 +97,7 @@ namespace MonoTests.System.Data
 			DataSet ds = new DataSet ();
 			ds.ReadXmlSchema (new StringReader (xs));
 			// Here "unusedType" table is never imported.
-			AssertDataSet ("ds", ds, "NewDataSet", 1);
+			AssertDataSet ("ds", ds, "hoge", 1);
 			AssertDataTable ("dt", ds.Tables [0], "Root", 1, 0);
 		}
 
@@ -106,7 +147,7 @@ namespace MonoTests.System.Data
 
 		[Test]
 		[ExpectedException (typeof (DataException))]
-		public void DataSetElementCannotBeReferenced ()
+		public void NestedReferenceNotAllowed ()
 		{
 			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
 	<xs:element name='Root' type='unusedType' msdata:IsDataSet='true'>
@@ -154,10 +195,10 @@ namespace MonoTests.System.Data
 		}
 
 		[Test]
-		public void ReadElemAttrPattern ()
+		public void LocaleOnRootWithoutIsDataSet ()
 		{
-			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
-	<xs:element name='Root'>
+			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
+	<xs:element name='Root' msdata:Locale='ja-JP'>
 		<xs:complexType>
 			<xs:sequence>
 				<xs:element name='Child' type='xs:string' />
@@ -170,10 +211,11 @@ namespace MonoTests.System.Data
 			DataSet ds = new DataSet ();
 			ds.ReadXmlSchema (new StringReader (xs));
 			AssertDataSet ("ds", ds, "NewDataSet", 1);
+			AssertEquals ("ja-JP", ds.Locale.Name);
 			DataTable dt = ds.Tables [0];
 			AssertDataTable ("dt", dt, "Root", 2, 0);
-			AssertDataColumn ("col1", dt.Columns [0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof (Int64), null, null, -1, String.Empty, 0, String.Empty, false, false);
-			AssertDataColumn ("col2", dt.Columns [1], "Child", false, false, 0, 1, "Child", MappingType.Element, typeof (string), null, null, -1, String.Empty, 1, String.Empty, false, false);
+			AssertDataColumn ("col1", dt.Columns [0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof (Int64), DBNull.Value, String.Empty, -1, String.Empty, 0, String.Empty, false, false);
+			AssertDataColumn ("col2", dt.Columns [1], "Child", false, false, 0, 1, "Child", MappingType.Element, typeof (string), DBNull.Value, String.Empty, -1, String.Empty, 1, String.Empty, false, false);
 		}
 
 
@@ -235,6 +277,63 @@ namespace MonoTests.System.Data
 			AssertEquals (0, ds.Relations.Count);
 		}
 
+		[Test]
+		public void PrefixedTargetNS ()
+		{
+			string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata' xmlns:x='urn:foo' targetNamespace='urn:foo' elementFormDefault='qualified'>
+	<xs:element name='DS' msdata:IsDataSet='true'>
+		<xs:complexType>
+			<xs:choice>
+				<xs:element ref='x:R1' />
+				<xs:element ref='x:R2' />
+			</xs:choice>
+		</xs:complexType>
+		<xs:key name='key'>
+			<xs:selector xpath='./any/string_is_OK/x:R1'/>
+			<xs:field xpath='x:Child2'/>
+		</xs:key>
+		<xs:keyref name='kref' refer='x:key'>
+			<xs:selector xpath='.//x:R2'/>
+			<xs:field xpath='x:Child2'/>
+		</xs:keyref>
+	</xs:element>
+	<xs:element name='R3' type='x:RootType' />
+	<xs:complexType name='extracted'>
+		<xs:choice>
+			<xs:element ref='x:R1' />
+			<xs:element ref='x:R2' />
+		</xs:choice>
+	</xs:complexType>
+	<xs:element name='R1' type='x:RootType'>
+		<xs:unique name='Rkey'>
+			<xs:selector xpath='.//x:Child1'/>
+			<xs:field xpath='.'/>
+		</xs:unique>
+		<xs:keyref name='Rkref' refer='x:Rkey'>
+			<xs:selector xpath='.//x:Child2'/>
+			<xs:field xpath='.'/>
+		</xs:keyref>
+	</xs:element>
+	<xs:element name='R2' type='x:RootType'>
+	</xs:element>
+	<xs:complexType name='RootType'>
+		<xs:choice>
+			<xs:element name='Child1' type='xs:string'>
+			</xs:element>
+			<xs:element name='Child2' type='xs:string' />
+		</xs:choice>
+		<xs:attribute name='Attr' type='xs:integer' />
+	</xs:complexType>
+</xs:schema>";
+			// No prefixes on tables and columns
+			DataSet ds = new DataSet ();
+			ds.ReadXmlSchema (new StringReader (xs));
+			AssertDataSet ("ds", ds, "DS", 3);
+			DataTable dt = ds.Tables [0];
+			AssertDataTable ("R3", dt, "R3", 3, 0);
+			AssertDataColumn ("col1", dt.Columns [0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof (Int64), DBNull.Value, String.Empty, -1, String.Empty, 0, String.Empty, false, false);
+		}
+
 		[Test]
 		public void ReadTest1 ()
 		{

+ 4 - 4
mcs/class/System.Data/Test/System.Data/DataSetTest.cs

@@ -838,24 +838,24 @@ namespace MonoTests.System.Data
                         set.Tables.Add (table);
                         set.Tables.Add (table1);                         DataColumn col = new DataColumn ();
                         col.ColumnName = "Id";
-                        col.DataType = System.Type.GetType ("System.Int32");
+                        col.DataType = Type.GetType ("System.Int32");
                         table.Columns.Add (col);
                         UniqueConstraint uc = new UniqueConstraint ("UK1", table.Columns[0] );
                         table.Constraints.Add (uc);
                                                                                                     
                         col = new DataColumn ();
                         col.ColumnName = "Name";
-                        col.DataType = System.Type.GetType ("System.String");
+                        col.DataType = Type.GetType ("System.String");
                         table.Columns.Add (col);
                                                                                                     
                         col = new DataColumn ();
                         col.ColumnName = "Id";
-                        col.DataType = System.Type.GetType ("System.Int32");
+                        col.DataType = Type.GetType ("System.Int32");
                         table1.Columns.Add (col);
                                                                                                     
                         col = new DataColumn ();
                         col.ColumnName = "Name";
-                        col.DataType = System.Type.GetType ("System.String");
+                        col.DataType = Type.GetType ("System.String");
 		        table1.Columns.Add (col);
 			  ForeignKeyConstraint fc = new ForeignKeyConstraint ("FK1", table.Columns[0], table1.Columns[0] );
                         table1.Constraints.Add (fc);