GetTotalCoverage() public static method

public static GetTotalCoverage ( string openCoverXml ) : string
openCoverXml string
return string
Example #1
0
        public void ThenIShouldHaveAResults_XmlFileWithACoverageGreaterThanOrEqualTo(int coveragePercentage)
        {
            var xml      = File.ReadAllText((string)ScenarioContext.Current["OutputXml"]);
            var coverage = Utils.GetTotalCoverage(xml) ?? "-1";

            Assert.GreaterOrEqual(decimal.Parse(coverage), coveragePercentage);
        }
Example #2
0
        public void ThenTheCoverageResultsShouldBeTheSame()
        {
            const string summaryRegEx     = @"(\<Summary\s.*?/\>)";
            const string seqPointRegEx    = @"(\<SequencePoint\s.*?/\>)";
            const string branchPointRegEx = @"(\<BranchPoint\s.*?/\>)";
            const string methodPointRegEx = @"(\<MethodPoint\s.*?/\>)";

            var output = (string)ScenarioContext.Current["targetOutput"];

            var outputXml86 = string.Format(@"{0}\{1}_{2}{3}",
                                            Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), "x86", Path.GetExtension(output));

            var outputXml64 = string.Format(@"{0}\{1}_{2}{3}",
                                            Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), "x64", Path.GetExtension(output));

            Assert.IsTrue(File.Exists(outputXml86));
            Assert.IsTrue(File.Exists(outputXml64));

            var data86 = File.ReadAllText(outputXml86);
            var data64 = File.ReadAllText(outputXml64);

            // do both files have the same coverage
            var coverage86 = Utils.GetTotalCoverage(data86);
            var coverage64 = Utils.GetTotalCoverage(data64);

            Assert.AreEqual(decimal.Parse(coverage64), decimal.Parse(coverage86));
            Assert.Greater(decimal.Parse(coverage64), 0);

            // do both files have the same number of elements Summary and Sequence points and are their attributes the same
            CompareMatches(Regex.Matches(data64, summaryRegEx, RegexOptions.Multiline), Regex.Matches(data86, summaryRegEx, RegexOptions.Multiline));
            CompareMatches(Regex.Matches(data64, seqPointRegEx, RegexOptions.Multiline), Regex.Matches(data86, seqPointRegEx, RegexOptions.Multiline));
            CompareMatches(Regex.Matches(data64, branchPointRegEx, RegexOptions.Multiline), Regex.Matches(data86, branchPointRegEx, RegexOptions.Multiline));
            CompareMatches(Regex.Matches(data64, methodPointRegEx, RegexOptions.Multiline), Regex.Matches(data86, methodPointRegEx, RegexOptions.Multiline));
        }