Example #1
0
        static void Main(string[] args)
        {
            string wspath = Environment.CurrentDirectory.ToString();

            Regex        isString = new Regex("(['\"]?)[a-zA-Z]*\\1$");
            CoverageInfo coverage = CoverageInfo.CreateFromFile(args[0]);

            CoverageDS data = coverage.BuildDataSet(null);


            string xml = data.GetXml();


            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xml);


            XslTransform  myXslTransform = new XslTransform();
            XmlTextWriter writer         = new XmlTextWriter(wspath + @"coverage.htm", null);

            myXslTransform.Load(wspath + @"\style.xslt");
            myXslTransform.Transform(xmlDocument, null, writer);

            writer.Flush();
            writer.Close();
        }
Example #2
0
        /// <summary>
        /// Write Transform Xml
        /// </summary>
        /// <param name="data">Coverage DataSet</param>
        /// <param name="outputPath">Output File Path</param>
        /// <param name="xslPath">Xsl File Path</param>
        private static void WriteTransformXml(CoverageDS data, string outputPath, string xslPath)
        {
            Console.WriteLine("xsl file: {0}", xslPath);

            using (XmlReader reader = new XmlTextReader(new StringReader(data.GetXml())))
            {
                using (XmlWriter writer = new XmlTextWriter(outputPath, Encoding.UTF8))
                {
                    XslCompiledTransform transform = new XslCompiledTransform();
                    transform.Load(xslPath);
                    transform.Transform(reader, writer);
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            string wspath = Environment.CurrentDirectory.ToString();

            Regex        isString = new Regex("(['\"]?)[a-zA-Z]*\\1$");
            CoverageInfo coverage = CoverageInfo.CreateFromFile(args[0]);

            CoverageDS data = coverage.BuildDataSet(null);


            string xml = data.GetXml();


            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xml);
            xmlDocument.Save("coverage.xml");
        }
        private static void ConvertCoverage(CoverageConverterArgument argument)
        {
            var testResultsDirectory = Path.Combine(argument.Workspace, argument.TestResultsFolder);

            var targetFilePath = Path.Combine(testResultsDirectory, argument.OutputFileName);

            if (Directory.Exists(testResultsDirectory) == false)
            {
                throw new DirectoryNotFoundException(string.Format("資料夾錯誤:資料夾【{0}】不存在!", testResultsDirectory));
            }
            else
            {
                var sourceCoverageFile = Directory.GetFiles(testResultsDirectory, "*.coverage", SearchOption.AllDirectories).OrderByDescending(f => File.GetLastWriteTime(f)).FirstOrDefault();

                if (File.Exists(sourceCoverageFile))
                {
                    CoverageInfo coverageInfo = CoverageInfo.CreateFromFile(sourceCoverageFile);

                    CoverageDS coverageDataSet = coverageInfo.BuildDataSet();

                    using (XmlReader reader = new XmlTextReader(new StringReader(coverageDataSet.GetXml())))
                    {
                        using (XmlWriter writer = new XmlTextWriter(targetFilePath, Encoding.UTF8))
                        {
                            var transform = new XslCompiledTransform();

                            transform.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MSTestCoverageToEmma.xsl"));

                            transform.Transform(reader, writer);
                        }
                    }

                    Console.WriteLine(string.Format("轉換檔案:【{0}】→【{1}】。", sourceCoverageFile, targetFilePath));
                }
                else
                {
                    throw new FileNotFoundException(string.Format("檔案錯誤:檔案【{0}】不存在!", sourceCoverageFile));
                }
            }
        }
Example #5
0
        public static int Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                DisplayUsage();
                return(0);
            }

            try
            {
                Arguments.Default = ArgumentProperties.Parse(args);

                if (!File.Exists(Arguments.DataCoverageFile))
                {
                    return(0);
                }

                using (CoverageInfo info = CoverageInfo.CreateFromFile(Arguments.DataCoverageFile))
                {
                    CoverageDS data = info.BuildDataSet();

                    string outputXml = Transform(data.GetXml());

                    XDocument doc = XDocument.Parse(outputXml);
                    ShortenMethodNames(doc);
                    File.WriteAllText(Arguments.XmlCoverageFile, doc.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
Example #6
0
        /// <summary>
        /// Write Transform Xml
        /// </summary>
        /// <param name="data">Coverage DataSet</param>
        /// <param name="outputPath">Output File Path</param>
        /// <param name="xslPath">Xsl File Path</param>
        private static void WriteTransformXml(CoverageDS data, string outputPath, string xslPath)
        {
            Console.WriteLine("xsl file: {0}", xslPath);

            using (XmlReader reader = new XmlTextReader(new StringReader(data.GetXml())))
            {
                using (XmlWriter writer = new XmlTextWriter(outputPath, Encoding.UTF8))
                {
                    XslCompiledTransform transform = new XslCompiledTransform();
                    transform.Load(xslPath);
                    transform.Transform(reader, writer);
                }
            }
        }