From: Oleg T. <he...@us...> - 2004-10-28 18:27:18
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17915/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs XIncludeSyntaxTests.cs XIncludeTest.csproj Log Message: Fixing bugs. Implemented non-streaming mode for text inclusion. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XIncludeTest.csproj 28 Oct 2004 13:01:53 -0000 1.7 +++ XIncludeTest.csproj 28 Oct 2004 18:27:06 -0000 1.8 @@ -87,7 +87,7 @@ /> <Reference Name = "System.XML" - AssemblyName = "System.XML" + AssemblyName = "System.Xml" HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> @@ -159,6 +159,10 @@ BuildAction = "Content" /> <File + RelPath = "results\includesitself-nohref-text.xml" + BuildAction = "Content" + /> + <File RelPath = "results\nonxmlchar.xml" BuildAction = "Content" /> @@ -215,6 +219,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\includesitself-nohref-text.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\nohref.xml" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- EntryPoint.cs 28 Oct 2004 13:01:52 -0000 1.8 +++ EntryPoint.cs 28 Oct 2004 18:27:05 -0000 1.9 @@ -9,14 +9,15 @@ { public static void Main() { - //XIncludeReaderTests rt = new XIncludeReaderTests(); - LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); + XIncludeReaderTests rt = new XIncludeReaderTests(); + //LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); //NistTests rt = new NistTests(); //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); //FourThoughtTests rt = new FourThoughtTests(); + //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.eduni_2(); + rt.IncludesItselfNoHrefText_NonStreaming(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- XIncludeReaderTests.cs 28 Oct 2004 13:01:52 -0000 1.9 +++ XIncludeReaderTests.cs 28 Oct 2004 18:27:06 -0000 1.10 @@ -22,24 +22,39 @@ Debug.Listeners.Add(new TextWriterTraceListener(Console.Error)); } + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) + { + RunAndCompare(source, result, textAsCDATA, true); + } /// <summary> /// Utility method for running tests. /// </summary> public static void RunAndCompare(string source, string result) { - RunAndCompare(source, result, false); + RunAndCompare(source, result, false, true); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompareNS(string source, string result) + { + RunAndCompare(source, result, false, false); } /// <summary> /// Utility method for running tests. /// </summary> - public static void RunAndCompare(string source, string result, bool textAsCDATA) + public static void RunAndCompare(string source, string result, bool textAsCDATA, bool streaming) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; - XIncludingReader xir = new XIncludingReader(source); - xir.ExposeTextInclusionsAsCDATA = textAsCDATA; + XIncludingReader xir = new XIncludingReader(source, streaming); + xir.ExposeTextInclusionsAsCDATA = textAsCDATA; try { doc.Load(xir); @@ -170,6 +185,15 @@ } /// <summary> + /// General test - it should work actually - non streaming. + /// </summary> + [Test] + public void ItWorksAtLeast_NonStreaming() + { + RunAndCompareNS("../../tests/document.xml", "../../results/document.xml"); + } + + /// <summary> /// Non XML character in the included document. /// </summary> [Test] @@ -180,6 +204,16 @@ } /// <summary> + /// Non XML character in the included document - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(NonXmlCharacterException))] + public void NonXMLChar_NonStreaming() + { + RunAndCompareNS("../../tests/nonxmlchar.xml", "../../results/nonxmlchar.xml"); + } + + /// <summary> /// File not found and no fallback. /// </summary> [Test] @@ -190,16 +224,52 @@ } /// <summary> - /// Circular inclusion. + /// File not found and no fallback - non streaming. /// </summary> [Test] - [ExpectedException(typeof(CircularInclusionException))] - public void IncludesItself() + [ExpectedException(typeof(FatalResourceException))] + public void FileNotFound_NonStreaming() + { + RunAndCompareNS("../../tests/filenotfound.xml", "../../results/filenotfound.xml"); + } + + /// <summary> + /// Includes itself by url. + /// </summary> + [Test] + public void IncludesItselfByUrl() { RunAndCompare("../../tests/includesitself.xml", "../../results/includesitself.xml"); } /// <summary> + /// Includes itself by url - non steraming. + /// </summary> + [Test] + public void IncludesItselfByUrl_NonStreaming() + { + RunAndCompareNS("../../tests/includesitself.xml", "../../results/includesitself.xml"); + } + + /// <summary> + /// Includes itself by url - no href - as text. + /// </summary> + [Test] + public void IncludesItselfNoHrefText() + { + RunAndCompare("../../tests/includesitself-nohref-text.xml", "../../results/includesitself-nohref-text.xml"); + } + + /// <summary> + /// Includes itself by url - no href - as text - non streaming. + /// </summary> + [Test] + public void IncludesItselfNoHrefText_NonStreaming() + { + RunAndCompareNS("../../tests/includesitself-nohref-text.xml", "../../results/includesitself-nohref-text.xml"); + } + + /// <summary> /// Text inclusion. /// </summary> [Test] @@ -209,6 +279,15 @@ } /// <summary> + /// Text inclusion - non streaming. + /// </summary> + [Test] + public void TextInclusion_NonStreaming() + { + RunAndCompareNS("../../tests/working_example.xml", "../../results/working_example.xml"); + } + + /// <summary> /// Text inclusion. /// </summary> [Test] @@ -218,6 +297,15 @@ } /// <summary> + /// Text inclusion - non streaming. + /// </summary> + [Test] + public void TextInclusion2_NonStreaming() + { + RunAndCompareNS("../../tests/working_example2.xml", "../../results/working_example2.xml"); + } + + /// <summary> /// Fallback. /// </summary> [Test] @@ -227,6 +315,16 @@ } /// <summary> + /// Fallback - non streaming. + /// </summary> + [Test] + public void Fallback_NonStreaming() + { + RunAndCompareNS("../../tests/fallback.xml", "../../results/fallback.xml"); + } + + + /// <summary> /// XPointer. /// </summary> [Test] @@ -236,6 +334,15 @@ } /// <summary> + /// XPointer - non streaming. + /// </summary> + [Test] + public void XPointer_NonStreaming() + { + RunAndCompareNS("../../tests/xpointer.xml", "../../results/xpointer.xml"); + } + + /// <summary> /// ReadOuterXml() test. /// </summary> [Test] @@ -255,6 +362,25 @@ } /// <summary> + /// ReadOuterXml() test - non streaming. + /// </summary> + [Test] + public void OuterXmlTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + string outerXml = xir.ReadOuterXml(); + xir.Close(); + xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + XmlDocument doc = new XmlDocument(); + doc.PreserveWhitespace = true; + doc.Load(xir); + string outerXml2 = doc.DocumentElement.OuterXml; + Assert.AreEqual(outerXml, outerXml2); + } + + /// <summary> /// ReadInnerXml() test. /// </summary> [Test] @@ -274,17 +400,58 @@ } /// <summary> + /// ReadInnerXml() test - non streaming. + /// </summary> + [Test] + public void InnerXmlTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + string innerXml = xir.ReadInnerXml(); + xir.Close(); + xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + XmlDocument doc = new XmlDocument(); + doc.PreserveWhitespace = true; + doc.Load(xir); + string innerXml2 = doc.DocumentElement.InnerXml; + Assert.AreEqual(innerXml, innerXml2); + } + + /// <summary> /// Depth test. /// </summary> [Test] public void DepthTest() { XIncludingReader xir = new XIncludingReader("../../tests/document.xml"); + StringBuilder sb = new StringBuilder(); + while (xir.Read()) + { + Console.WriteLine("{0} | {1} | {2} | {3}", + xir.NodeType, xir.Name, xir.Value, xir.Depth); + sb.Append(xir.Depth); + } + string expected = "00011211111111223221100"; + Assert.AreEqual(sb.ToString(), expected); + } + + /// <summary> + /// Depth test - non streaming. + /// </summary> + [Test] + public void DepthTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + StringBuilder sb = new StringBuilder(); while (xir.Read()) { Console.WriteLine("{0} | {1} | {2} | {3}", xir.NodeType, xir.Name, xir.Value, xir.Depth); + sb.Append(xir.Depth); } + string expected = "00011211111111223221100"; + Assert.AreEqual(sb.ToString(), expected); } // /// <summary> Index: XIncludeSyntaxTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeSyntaxTests.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XIncludeSyntaxTests.cs 16 Oct 2004 21:01:37 -0000 1.2 +++ XIncludeSyntaxTests.cs 28 Oct 2004 18:27:06 -0000 1.3 @@ -31,6 +31,18 @@ } /// <summary> + /// No href and no xpointer attribute - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(MissingHrefAndXpointerException))] + public void NoHrefAndNoXPointerAttributes_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/nohref.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// xi:include child of xi:include. /// </summary> [Test] @@ -40,7 +52,19 @@ XIncludingReader xir = new XIncludingReader("../../tests/includechildofinclude.xml"); while (xir.Read()); xir.Close(); - } + } + + /// <summary> + /// xi:include child of xi:include - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void IncludeChildOfInclude_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/includechildofinclude.xml", false); + while (xir.Read()); + xir.Close(); + } /// <summary> /// xi:fallback not child of xi:include. @@ -55,6 +79,18 @@ } /// <summary> + /// xi:fallback not child of xi:include - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void FallbackNotChildOfInclude_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/fallbacknotchildinclude.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// Unknown value of parse attribute. /// </summary> [Test] @@ -67,6 +103,18 @@ } /// <summary> + /// Unknown value of parse attribute - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(UnknownParseAttributeValueException))] + public void UnknownParseAttribute_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/unknownparseattr.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// Two xi:fallback. /// </summary> [Test] @@ -77,5 +125,18 @@ while (xir.Read()); xir.Close(); } + + /// <summary> + /// Two xi:fallback - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void TwoFallbacks_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/twofallbacks.xml", false); + while (xir.Read()); + xir.Close(); + } + } } |