Merge pull request #1624 from esdrubal/getprocesstimes
[mono.git] / mcs / class / System.Data / Test / System.Data / DataSetInferXmlSchemaTest.cs
old mode 100755 (executable)
new mode 100644 (file)
index 06cf50c..daec352
@@ -47,31 +47,31 @@ namespace MonoTests.System.Data
                string xml4 = "<root>simple.txt</root>";
                string xml5 = "<root><child/></root>";
                string xml6 = "<root><col1>sample</col1></root>";
-               string xml7 = @"<root>\r
-<col1>column 1 test</col1>\r
-<col2>column2test</col2>\r
-<col3>3get</col3>\r
-</root>";\r
-               string xml8 = @"<set>\r
-<tab>\r
-<col1>1</col1>\r
-<col2>1</col2>\r
-<col3>1</col3>\r
-</tab>\r
-</set>";\r
-               string xml9 = @"<el1 attr1='val1' attrA='valA'>\r
-  <el2 attr2='val2' attrB='valB'>\r
-    <el3 attr3='val3' attrC='valC'>3</el3>\r
-      <column2>1</column2>\r
-      <column3>1</column3>\r
-    <el4 attr4='val4' attrD='valD'>4</el4>\r
-  </el2>\r
+               string xml7 = @"<root>
+<col1>column 1 test</col1>
+<col2>column2test</col2>
+<col3>3get</col3>
+</root>";
+               string xml8 = @"<set>
+<tab>
+<col1>1</col1>
+<col2>1</col2>
+<col3>1</col3>
+</tab>
+</set>";
+               string xml9 = @"<el1 attr1='val1' attrA='valA'>
+  <el2 attr2='val2' attrB='valB'>
+    <el3 attr3='val3' attrC='valC'>3</el3>
+      <column2>1</column2>
+      <column3>1</column3>
+    <el4 attr4='val4' attrD='valD'>4</el4>
+  </el2>
 </el1>";
                // mixed content
                string xml10 = "<root>Here is a <b>mixed</b> content.</root>";
                // xml:space support
-               string xml11 = @"<root xml:space='preserve'>\r
-   <child_after_significant_space />\r
+               string xml11 = @"<root xml:space='preserve'>
+   <child_after_significant_space />
 </root>";
                // This is useless ... since xml:space becomes a DataColumn here.
 //             string xml12 = "<root xml:space='preserve'>     </root>";
@@ -85,89 +85,90 @@ namespace MonoTests.System.Data
                // simple namespace/prefix support
                string xml14 = "<p:root xmlns:p='urn:foo'>test string</p:root>";
                // two tables that have the same content type.
-               string xml15 = @"<root>\r
-<table1>\r
-        <col1_1>test1</col1_1>\r
-        <col1_2>test2</col1_2>\r
-</table1>\r
-<table2>\r
-        <col2_1>test1</col2_1>\r
-        <col2_2>test2</col2_2>\r
-</table2>\r
+               string xml15 = @"<root>
+<table1>
+        <col1_1>test1</col1_1>
+        <col1_2>test2</col1_2>
+</table1>
+<table2>
+        <col2_1>test1</col2_1>
+        <col2_2>test2</col2_2>
+</table2>
 </root>";
                // foo cannot be both table chikd and root child
-               string xml16 = @"<root>\r
-<table>\r
-        <foo>\r
-                <tableFooChild1>1</tableFooChild1>\r
-                <tableFooChild2>2</tableFooChild2>\r
-        </foo>\r
-        <bar />\r
-</table>\r
-<foo></foo>\r
-<bar />\r
+               string xml16 = @"<root>
+<table>
+        <foo>
+                <tableFooChild1>1</tableFooChild1>
+                <tableFooChild2>2</tableFooChild2>
+        </foo>
+        <bar />
+</table>
+<foo></foo>
+<bar />
 </root>";
                // simple namespace support
                string xml17 = @"<root xmlns='urn:foo' />";
                // conflict between simple and complex type element col
-               string xml18 = @"<set>\r
-<table>\r
-<col>\r
-        <another_col />\r
-</col>\r
-<col>simple text here.</col>\r
-</table>\r
+               string xml18 = @"<set>
+<table>
+<col>
+        <another_col />
+</col>
+<col>simple text here.</col>
+</table>
 </set>";
                // variant of xml18: complex column appeared latter
-               string xml19 =@"<set>\r
-<table>\r
-<col>simple text</col><!-- ignored -->\r
-<col>\r
-        <another_col />\r
-</col>\r
-</table>\r
+               string xml19 =@"<set>
+<table>
+<col>simple text</col><!-- ignored -->
+<col>
+        <another_col />
+</col>
+</table>
 </set>";
                // conflict check (actually it is not conflict) on two "col" tables
-               string xml20 = @"<set>\r
-<table>\r
-<col>\r
-        <another_col />\r
-</col>\r
-<col attr='value' />\r
-</table>\r
+               string xml20 = @"<set>
+<table>
+<col>
+        <another_col />
+</col>
+<col attr='value' />
+</table>
 </set>";
                // conflict between the attribute and the child element
-               string xml21 = @"<set>\r
-<table>\r
-<col data='value'>\r
-        <data />\r
-</col>\r
-</table>\r
+               string xml21 = @"<set>
+<table>
+<col data='value'>
+        <data />
+</col>
+</table>
 </set>";
                // simple nest
-               string xml22 = "<set><table><col><descendant/></col></table><table2><col2>v2</col2></table2></set>";\r
-               // simple diffgram\r
-               string xml23 = @"<set>\r
-  <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\r
-    <xs:element name='table'>\r
-      <xs:complexType>\r
-      <xs:choice>\r
-        <xs:any />\r
-      </xs:choice>\r
-      </xs:complexType>\r
-    </xs:element>\r
-  </xs:schema>\r
-  <diffgr:diffgram\r
-        xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'\r
-        xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>\r
-    <table>\r
-      <col>1</col>\r
-    </table>\r
-  </diffgr:diffgram>\r
-</set>";\r
-               // just deep table\r
-               string xml24 = "<p1><p2><p3><p4><p5><p6/></p5></p4></p3></p2></p1>";\r
-\r
+               string xml22 = "<set><table><col><descendant/></col></table><table2><col2>v2</col2></table2></set>";
+         /*
+               // simple diffgram
+               string xml23 = @"<set>
+  <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+    <xs:element name='table'>
+      <xs:complexType>
+      <xs:choice>
+        <xs:any />
+      </xs:choice>
+      </xs:complexType>
+    </xs:element>
+  </xs:schema>
+  <diffgr:diffgram
+        xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'
+        xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>
+    <table>
+      <col>1</col>
+    </table>
+  </diffgr:diffgram>
+</set>";
+               // just deep table
+               string xml24 = "<p1><p2><p3><p4><p5><p6/></p5></p4></p3></p2></p1>";
+         */
 
                private DataSet GetDataSet (string xml, string [] nss)
                {
@@ -196,12 +197,12 @@ namespace MonoTests.System.Data
                        // namespaces
                        ds = GetDataSet (xml14, null);
                        AssertDataSet ("xml14", ds, "root", 0, 0);
-                       AssertEquals ("p", ds.Prefix);
-                       AssertEquals ("urn:foo", ds.Namespace);
+                       Assert.AreEqual (string.Empty, ds.Prefix);
+                       Assert.AreEqual ("urn:foo", ds.Namespace);
 
                        ds = GetDataSet (xml17, null);
                        AssertDataSet ("xml17", ds, "root", 0, 0);
-                       AssertEquals ("urn:foo", ds.Namespace);
+                       Assert.AreEqual ("urn:foo", ds.Namespace);
                }
 
                [Test]
@@ -323,9 +324,9 @@ namespace MonoTests.System.Data
                        DataSet ds = GetDataSet (xml11, null);
                        AssertDataSet ("ds", ds, "NewDataSet", 1, 0);
                        DataTable dt = ds.Tables [0];
-                       AssertDataTable ("dt", dt, "root", 2, 0, 0, 0, 0, 0);
+                       AssertDataTable ("dt", dt, "root", 1, 0, 0, 0, 0, 0);
                        AssertDataColumn ("element", dt.Columns [0], "child_after_significant_space", true, false, 0, 1, "child_after_significant_space", MappingType.Element, typeof (string), DBNull.Value, String.Empty, -1, String.Empty, 0, String.Empty, false, false);
-                       AssertDataColumn ("xml:space", dt.Columns [1], "space", true, false, 0, 1, "space", MappingType.Attribute, typeof (string), DBNull.Value, String.Empty, -1, "http://www.w3.org/XML/1998/namespace", 1, "xml", false, false);
+                       Assert.AreEqual (1, dt.Columns.Count, "xml:space is not treated as column");
                }
 
                [Test]
@@ -334,14 +335,14 @@ namespace MonoTests.System.Data
                        // To make sure, create pure significant whitespace element
                        // using XmlNodeReader (that does not have xml:space attribute
                        // column).
-                       DataSet ds = new DataSet ();\r
-                       XmlDocument doc = new XmlDocument ();\r
-                       doc.AppendChild (doc.CreateElement ("root"));\r
-                       doc.DocumentElement.AppendChild (doc.CreateSignificantWhitespace\r
-                       ("      \n\n"));\r
-                       XmlReader xr = new XmlNodeReader (doc);\r
-                       ds.InferXmlSchema (xr, null);\r
-                       AssertDataSet ("pure_whitespace", ds, "root", 0, 0);\r
+                       DataSet ds = new DataSet ();
+                       XmlDocument doc = new XmlDocument ();
+                       doc.AppendChild (doc.CreateElement ("root"));
+                       doc.DocumentElement.AppendChild (doc.CreateSignificantWhitespace
+                       ("      \n\n"));
+                       XmlReader xr = new XmlNodeReader (doc);
+                       ds.InferXmlSchema (xr, null);
+                       AssertDataSet ("pure_whitespace", ds, "root", 0, 0);
                }
 
                [Test]
@@ -364,6 +365,7 @@ namespace MonoTests.System.Data
                }
 
                [Test]
+               [Category ("NotWorking")]
                [ExpectedException (typeof (ArgumentException))]
                // The same table cannot be the child table in two nested relations.
                public void ComplexElementTable1 ()
@@ -472,14 +474,14 @@ namespace MonoTests.System.Data
                [ExpectedException (typeof (ConstraintException))]
                public void ConflictExistingPrimaryKey ()
                {
-                       // The 'col' DataTable tries to create another primary key (and fails)\r
-                       DataSet ds = new DataSet ();\r
-                       ds.Tables.Add (new DataTable ("table"));\r
-                       DataColumn c = new DataColumn ("pk");\r
-                       ds.Tables [0].Columns.Add (c);\r
-                       ds.Tables [0].PrimaryKey = new DataColumn [] {c};\r
-                       XmlTextReader xtr = new XmlTextReader (xml22, XmlNodeType.Document, null);\r
-                       xtr.Read ();\r
+                       // <wrong>The 'col' DataTable tries to create another primary key (and fails)</wrong> The data violates key constraint.
+                       DataSet ds = new DataSet ();
+                       ds.Tables.Add (new DataTable ("table"));
+                       DataColumn c = new DataColumn ("pk");
+                       ds.Tables [0].Columns.Add (c);
+                       ds.Tables [0].PrimaryKey = new DataColumn [] {c};
+                       XmlTextReader xtr = new XmlTextReader (xml22, XmlNodeType.Document, null);
+                       xtr.Read ();
                        ds.ReadXml (xtr, XmlReadMode.InferSchema);
                }
 
@@ -526,7 +528,7 @@ namespace MonoTests.System.Data
                        ds.WriteXml(sw);
                        XmlDocument doc = new XmlDocument ();
                        doc.LoadXml (sw.ToString ());
-                       AssertEquals (2, doc.DocumentElement.ChildNodes.Count);
+                       Assert.AreEqual (2, doc.DocumentElement.ChildNodes.Count);
                }
        }
 }