コード例 #1
0
        /// <summary>
        /// Writes out an HTML file showing any differecnes between the two specified files.
        /// </summary>
        /// <param name="expectedXmlFile">The "expected" or "source" XML file used in the comparison.</param>
        /// <param name="actualXmlFile">The "actual" or "changed" XML file used in the comparison.</param>
        /// <param name="bIdentical">True if the two files were found to be identical.</param>
        /// <param name="xmlDiffGram">The xml DiffGram from the XmlDiff tool describing the differences between the two files.</param>
        /// <param name="resultHtmlViewFile">The path and name of the HTML file this function should save.</param>
        internal static void WriteHtmlDiffViewFile(string expectedXmlFile, string actualXmlFile, bool bIdentical, string xmlDiffGram, string resultHtmlViewFile)
        {
            // Write HTML View File:
            TextWriter resultHtml = new StreamWriter(new FileStream(resultHtmlViewFile, FileMode.Create, FileAccess.Write));

            resultHtml.WriteLine("<html><head>");
            resultHtml.WriteLine("<style TYPE='text/css' MEDIA='screen'>");
            resultHtml.Write("<!-- td { font-family: Courier New; font-size:14; } " + "th { font-family: Arial; } " + "p { font-family: Arial; } -->");
            resultHtml.WriteLine("</style></head>");
            resultHtml.WriteLine("<body><h3 style='font-family:Arial'>XmlDiff view</h3><table border='0'><tr><td><table border='0'>");
            resultHtml.WriteLine("<tr><th>" + expectedXmlFile + "</th><th>" + actualXmlFile + "</th></tr>" + "<tr><td colspan=2><hr size=1></td></tr>");
            if (bIdentical)
            {
                resultHtml.WriteLine("<tr><td colspan='2' align='middle'>Files are identical.</td></tr>");
            }
            else
            {
                resultHtml.WriteLine("<tr><td colspan='2' align='middle'>Files are different.</td></tr>");
            }

            var masterReader = new XmlTextReader(expectedXmlFile);
            var xmlDiffView  = new XmlDiffView.XmlDiffView();

            masterReader.XmlResolver = null;
            xmlDiffView.Load(masterReader, new XmlTextReader(new StringReader(xmlDiffGram)));

            xmlDiffView.GetHtml(resultHtml);
            masterReader.Close();

            resultHtml.WriteLine("</table></table></body></html>");
            resultHtml.Close();
        }
コード例 #2
0
        private static void WriteHtmlDiffViewFile(XmlReader expectedDocumentReader, bool bIdentical, string xmlDiffGram, string resultHtmlFile)
        {
            // Write HTML View File:
            TextWriter resultHtml = new StreamWriter(new FileStream(resultHtmlFile, FileMode.Create, FileAccess.Write));

            resultHtml.WriteLine("<html><head>");
            resultHtml.WriteLine("<style TYPE='text/css' MEDIA='screen'>");
            resultHtml.Write("<!-- td { font-family: Courier New; font-size:14; } " + "th { font-family: Arial; } " + "p { font-family: Arial; } -->");
            resultHtml.WriteLine("</style></head>");
            resultHtml.WriteLine("<body><h3 style='font-family:Arial'>XmlDiff view</h3><table border='0'><tr><td><table border='0'>");
            resultHtml.WriteLine("<tr><th>" + "ExpectedOutput Style File" + "</th><th>" + "ActualOutput Style File" + "</th></tr>" + "<tr><td colspan=2><hr size=1></td></tr>");

            resultHtml.WriteLine(bIdentical
                                ? "<tr><td colspan='2' align='middle'>Files are identical.</td></tr>"
                                : "<tr><td colspan='2' align='middle'>Files are different.</td></tr>");

            var xmlDiffView = new QaKit.FileComparer.XML.XmlDiffView.XmlDiffView();

            xmlDiffView.Load(expectedDocumentReader, new XmlTextReader(new StringReader(xmlDiffGram)));

            xmlDiffView.GetHtml(resultHtml);
            expectedDocumentReader.Close();

            resultHtml.WriteLine("</table></table></body></html>");
            resultHtml.Close();
        }