Remove fixed testcases from fixme.lst and knownFailures.lst; ignore one testcase...
[mono.git] / mcs / class / System.XML / Test / System.Xml / XmlReaderCommonTests.cs
index 0014698966e19122772fb1cbd852fa5701b3f5e5..dc7c4bc113f8e798b6462d0442503a4a80de18a8 100644 (file)
@@ -13,6 +13,7 @@ using System;
 using System.IO;\r
 using System.Text;\r
 using System.Xml;\r
+using System.Xml.Schema;\r
 using System.Xml.XPath;\r
 \r
 using NUnit.Framework;\r
@@ -61,10 +62,14 @@ namespace MonoTests.System.Xml
                        Assert ("Read() return value", xmlReader.Read ());\r
                        Assert ("ReadState", xmlReader.ReadState == ReadState.Interactive);\r
                        Assert ("!EOF", !xmlReader.EOF);\r
-                       AssertNodeValues (xmlReader, nodeType, depth, isEmptyElement, name, prefix, localName, namespaceURI, value, attributeCount);\r
+                       AssertNodeValues ("", xmlReader, nodeType, depth,\r
+                               isEmptyElement, name, prefix, localName,\r
+                               namespaceURI, value, value != String.Empty,\r
+                               attributeCount, attributeCount > 0);\r
                }\r
 \r
                private void AssertNodeValues (\r
+                       string label,\r
                        XmlReader xmlReader,\r
                        XmlNodeType nodeType,\r
                        int depth,\r
@@ -76,10 +81,14 @@ namespace MonoTests.System.Xml
                        string value,\r
                        int attributeCount)\r
                {\r
-                       AssertNodeValues (xmlReader, nodeType, depth, isEmptyElement, name, prefix, localName, namespaceURI, value, value != String.Empty, attributeCount, attributeCount > 0);\r
+                       AssertNodeValues (label, xmlReader, nodeType, depth,\r
+                               isEmptyElement, name, prefix, localName,\r
+                               namespaceURI, value, value != String.Empty,\r
+                               attributeCount, attributeCount > 0);\r
                }\r
 \r
                private void AssertNodeValues (\r
+                       string label,\r
                        XmlReader xmlReader,\r
                        XmlNodeType nodeType,\r
                        int depth,\r
@@ -93,26 +102,27 @@ namespace MonoTests.System.Xml
                        int attributeCount,\r
                        bool hasAttributes)\r
                {\r
-                       AssertEquals ("NodeType", nodeType, xmlReader.NodeType);\r
-                       AssertEquals ("IsEmptyElement", isEmptyElement, xmlReader.IsEmptyElement);\r
+                       label = String.Concat (label, "(", xmlReader.GetType ().Name, ")");\r
+                       AssertEquals (label + ": NodeType", nodeType, xmlReader.NodeType);\r
+                       AssertEquals (label + ": IsEmptyElement", isEmptyElement, xmlReader.IsEmptyElement);\r
 \r
-                       AssertEquals ("name", name, xmlReader.Name);\r
+                       AssertEquals (label + ": name", name, xmlReader.Name);\r
 \r
-                       AssertEquals ("prefix", prefix, xmlReader.Prefix);\r
+                       AssertEquals (label + ": prefix", prefix, xmlReader.Prefix);\r
 \r
-                       AssertEquals ("localName", localName, xmlReader.LocalName);\r
+                       AssertEquals (label + ": localName", localName, xmlReader.LocalName);\r
 \r
-                       AssertEquals ("namespaceURI", namespaceURI, xmlReader.NamespaceURI);\r
+                       AssertEquals (label + ": namespaceURI", namespaceURI, xmlReader.NamespaceURI);\r
 \r
-                       AssertEquals ("Depth", depth, xmlReader.Depth);\r
+                       AssertEquals (label + ": Depth", depth, xmlReader.Depth);\r
 \r
-                       AssertEquals ("hasValue", hasValue, xmlReader.HasValue);\r
+                       AssertEquals (label + ": hasValue", hasValue, xmlReader.HasValue);\r
 \r
-                       AssertEquals ("Value", value, xmlReader.Value);\r
+                       AssertEquals (label + ": Value", value, xmlReader.Value);\r
 \r
-                       AssertEquals ("hasAttributes", hasAttributes, xmlReader.HasAttributes);\r
+                       AssertEquals (label + ": hasAttributes", hasAttributes, xmlReader.HasAttributes);\r
 \r
-                       AssertEquals ("attributeCount", attributeCount, xmlReader.AttributeCount);\r
+                       AssertEquals (label + ": attributeCount", attributeCount, xmlReader.AttributeCount);\r
                }\r
 \r
                private void AssertAttribute (\r
@@ -169,6 +179,14 @@ namespace MonoTests.System.Xml
                        document.LoadXml (xml);\r
                        xnr = new XmlNodeReader (document);\r
                        method (xnr);\r
+#if NET_2_0\r
+/*\r
+                       // XPathNavigatorReader tests\r
+                       System.Xml.XPath.XPathDocument doc = new System.Xml.XPath.XPathDocument (new StringReader (xml));\r
+                       XmlReader xpr = doc.CreateNavigator ().ReadSubtree ();\r
+                       method (xpr);\r
+*/\r
+#endif\r
                }\r
 \r
 \r
@@ -223,6 +241,7 @@ namespace MonoTests.System.Xml
                }\r
 \r
                [Test]\r
+               [Category ("NotDotNet")]\r
                public void ReadAttributeValue ()\r
                {\r
                        RunTest ("<root attr=''/>", new TestMethod (ReadAttributeValue));\r
@@ -234,14 +253,18 @@ namespace MonoTests.System.Xml
                        Assert (reader.MoveToFirstAttribute ());\r
                        // It looks like that MS.NET shows AttributeCount and\r
                        // HasAttributes as the same as element node!\r
-                       this.AssertNodeValues (reader, XmlNodeType.Attribute,\r
+                       this.AssertNodeValues ("#1",\r
+                               reader, XmlNodeType.Attribute,\r
                                1, false, "attr", "", "attr", "", "", true, 1, true);\r
                        Assert (reader.ReadAttributeValue ());\r
-                       // MS.NET XmlTextReader fails. Its Prefix returns null instead of "".\r
-                       this.AssertNodeValues (reader, XmlNodeType.Text,\r
+                       // MS.NET XmlTextReader fails. Its Prefix returns \r
+                       // null instead of "". It is fixed in MS.NET 2.0.\r
+                       this.AssertNodeValues ("#2",\r
+                               reader, XmlNodeType.Text,\r
                                2, false, "", "", "", "", "", true, 1, true);\r
                        Assert (reader.MoveToElement ());\r
-                       this.AssertNodeValues (reader, XmlNodeType.Element,\r
+                       this.AssertNodeValues ("#3",\r
+                               reader, XmlNodeType.Element,\r
                                0, true, "root", "", "root", "", "", false, 1, true);\r
                }\r
 \r
@@ -1192,6 +1215,7 @@ namespace MonoTests.System.Xml
                        Assert (xmlReader.MoveToElement ());\r
 \r
                        AssertNodeValues (\r
+                               "#1",\r
                                xmlReader, // xmlReader\r
                                XmlNodeType.Element, // nodeType\r
                                0, //depth\r
@@ -1208,7 +1232,8 @@ namespace MonoTests.System.Xml
                }\r
 \r
                [Test]\r
-               [Ignore ("XmlNodeReader never moves to xml declaration.")]\r
+//             [Category ("NotDotNet")] // MS XmlNodeReader never moves to xml declaration.\r
+               [Ignore ("Too inconsistent reference implementations to determine which is correct behavior.")]\r
                public void MoveToXmlDeclAttributes ()\r
                {\r
                        string xml = "<?xml version=\"1.0\" standalone=\"yes\"?><root/>";\r
@@ -1218,7 +1243,7 @@ namespace MonoTests.System.Xml
                public void MoveToXmlDeclAttributes (XmlReader xmlReader)\r
                {\r
                        xmlReader.Read ();\r
-                       this.AssertNodeValues (xmlReader, \r
+                       this.AssertNodeValues ("#1", xmlReader, \r
                                XmlNodeType.XmlDeclaration,\r
                                0,\r
                                false,\r
@@ -1228,10 +1253,11 @@ namespace MonoTests.System.Xml
                                String.Empty,\r
                                "version=\"1.0\" standalone=\"yes\"",\r
                                2);\r
-                       xmlReader.MoveToFirstAttribute ();\r
-                       this.AssertNodeValues (xmlReader, \r
+                       Assert ("MoveToFirstAttribute",\r
+                               xmlReader.MoveToFirstAttribute ());\r
+                       this.AssertNodeValues ("#2", xmlReader, \r
                                XmlNodeType.Attribute,\r
-                               1,\r
+                               0, // FIXME: might be 1\r
                                false,\r
                                "version",\r
                                String.Empty,\r
@@ -1240,20 +1266,20 @@ namespace MonoTests.System.Xml
                                "1.0",\r
                                2);\r
                        xmlReader.ReadAttributeValue ();\r
-                       this.AssertNodeValues (xmlReader, \r
+                       this.AssertNodeValues ("#3", xmlReader, \r
                                XmlNodeType.Text,\r
-                               2,\r
+                               1, // FIXME might be 2\r
                                false,\r
                                String.Empty,\r
+                               null, // FIXME: should be String.Empty,\r
                                String.Empty,\r
-                               String.Empty,\r
-                               String.Empty,\r
+                               null, // FIXME: should be String.Empty,\r
                                "1.0",\r
                                2);\r
                        xmlReader.MoveToNextAttribute ();\r
-                       this.AssertNodeValues (xmlReader, \r
+                       this.AssertNodeValues ("#4", xmlReader, \r
                                XmlNodeType.Attribute,\r
-                               1,\r
+                               0, // FIXME: might be 1\r
                                false,\r
                                "standalone",\r
                                String.Empty,\r
@@ -1262,14 +1288,14 @@ namespace MonoTests.System.Xml
                                "yes",\r
                                2);\r
                        xmlReader.ReadAttributeValue ();\r
-                       this.AssertNodeValues (xmlReader, \r
+                       this.AssertNodeValues ("#5", xmlReader, \r
                                XmlNodeType.Text,\r
-                               2,\r
+                               1, // FIXME: might be 2\r
                                false,\r
                                String.Empty,\r
+                               null, // FIXME: should be String.Empty,\r
                                String.Empty,\r
-                               String.Empty,\r
-                               String.Empty,\r
+                               null, // FIXME: should be String.Empty,\r
                                "yes",\r
                                2);\r
                }\r
@@ -1297,6 +1323,7 @@ namespace MonoTests.System.Xml
                }\r
 \r
                [Test]\r
+               [Category ("NotDotNet")]\r
                public void IndexerAndAttributes ()\r
                {\r
                        string xml = @"<?xml version='1.0' standalone='no'?><foo _1='1' _2='2' _3='3' />";\r
@@ -1372,5 +1399,35 @@ namespace MonoTests.System.Xml
                        AssertEquals (0xD800, (int) xmlReader.Value [0]);\r
                        AssertEquals (0xDD00, (int) xmlReader.Value [1]);\r
                }\r
+\r
+               [Test]\r
+               public void ReadOuterXmlOnEndElement ()\r
+               {\r
+                       string xml = "<root><foo></foo></root>";\r
+                       RunTest (xml, new TestMethod (ReadOuterXmlOnEndElement));\r
+               }\r
+\r
+               public void ReadOuterXmlOnEndElement (XmlReader xmlReader)\r
+               {\r
+                       xmlReader.Read ();\r
+                       xmlReader.Read ();\r
+                       xmlReader.Read ();\r
+                       AssertEquals (String.Empty, xmlReader.ReadOuterXml ());\r
+               }\r
+\r
+               [Test]\r
+               public void ReadInnerXmlOnEndElement ()\r
+               {\r
+                       string xml = "<root><foo></foo></root>";\r
+                       RunTest (xml, new TestMethod (ReadInnerXmlOnEndElement));\r
+               }\r
+\r
+               private void ReadInnerXmlOnEndElement (XmlReader xmlReader)\r
+               {\r
+                       xmlReader.Read ();\r
+                       xmlReader.Read ();\r
+                       xmlReader.Read ();\r
+                       AssertEquals (String.Empty, xmlReader.ReadInnerXml ());\r
+               }\r
        }\r
 }\r