Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockCoverage"/> class.
 /// </summary>
 /// <param name="id">Block identification.</param>
 /// <param name="file"><see cref="FileSpec"/> containing the instrumented line.</param>
 /// <param name="lineStart">Starting line of code coverage block.</param>
 /// <param name="lineEnd">Ending line of code coverage block.</param>
 /// <param name="columnStart">Starting column of code coverage block.</param>
 /// <param name="columnEnd">Ending column of code coverage block.</param>
 /// <param name="coverage">Block coverage status.</param>
 internal BlockCoverage(FileSpec file, long lineStart, long lineEnd, long columnStart, long columnEnd, CoverageStatus coverage)
 {
     File = file;
     LineStart = lineStart;
     LineEnd = lineEnd;
     ColumnStart = columnStart;
     ColumnEnd = columnEnd;
     Coverage = coverage;
 }
Ejemplo n.º 2
0
        private void CoverageStatusShouldBe(int coverage, int newCoverage, CoverageStatus result)
        {
            //// Arrange
            var reportEntity = new CoverageEntity();

            reportEntity.Coverage = newCoverage;

            var target = new CoverageEntity();

            target.Coverage = coverage;

            //// Act
            target.UpdateCoverage(reportEntity);

            //// Assert
            target.Status.Should().Be(result);
        }
Ejemplo n.º 3
0
        // Not Required anymore

        /*public static List<CoverageDSPriv.LinesRow> DataRowToList(CoverageDS coverageDS, string sourceFile)
         * {
         *  uint fileId = coverageDS.FindSourceFileId(sourceFile);
         *  string filter = string.Format(CultureInfo.InvariantCulture, "SourceFileID = {0}", fileId);
         *  DataRow[] rows = coverageDS.Lines.Select(filter);
         *
         *  List<CoverageDSPriv.LinesRow> allLines = new List<CoverageDSPriv.LinesRow>();
         *  foreach (DataRow dataRow in rows)
         *  {
         *      if (dataRow.RowState == DataRowState.Deleted || dataRow.RowState == DataRowState.Detached)
         *          continue;
         *
         *      CoverageDSPriv.LinesRow row = dataRow as CoverageDSPriv.LinesRow;
         *
         *      allLines.Add(row);
         *  }
         *
         *  return allLines;
         * }*/

        //this is just manipulation of LineCoverageInfo
        //Each LineCoverageInfo is a range of lines

        /*for example:
         *              startLine   EndLine   Status
         * range 1          13          17      C
         * range 2          13          17      N
         * range 3          13          17      C
         *
         * after pasrsign 1st range we will say covered, then after parssing 2nd we will say not coverred,
         * finally after parsing 3rd range it will say covered.
         *
         * it's weird but like I said, either we are getting extremely lucky and it might screw us later,
         * or I'm missing something somewhere in code
         */

        public static void AnalyzeMergedLines(IList <LineCoverageInfo> lineInfo)
        {
            //first we remove dumplicates by using map, after this each line is only present once, no more line ranges.
            Dictionary <uint, CoverageStatus> lineMap = new Dictionary <uint, CoverageStatus>();

            foreach (LineCoverageInfo info in lineInfo)
            {
                for (uint lineNum = info.LineBegin; lineNum <= info.LineEnd; lineNum++)
                {
                    lineMap[lineNum] = info.CoverageStatus;
                }
            }

            HashSet <uint> coveredLines          = new HashSet <uint>();
            HashSet <uint> notCoveredLines       = new HashSet <uint>();
            HashSet <uint> partiallyCoveredLines = new HashSet <uint>();

            //on getting this Map, add data to list(s) of covered, notcovered and partially covered
            // Note: not iterating over ranges here
            foreach (KeyValuePair <uint, CoverageStatus> kvp in lineMap)
            {
                CoverageStatus status = kvp.Value;
                switch (status)
                {
                case CoverageStatus.Covered:
                    coveredLines.Add(kvp.Key);
                    break;

                case CoverageStatus.NotCovered:
                    notCoveredLines.Add(kvp.Key);
                    break;

                case CoverageStatus.PartiallyCovered:
                    partiallyCoveredLines.Add(kvp.Key);
                    break;
                }
            }

            Console.WriteLine($"CoveredLines: {string.Join(",", coveredLines)}");
            Console.WriteLine($"Not covered lines: {string.Join(",", notCoveredLines)}");
            Console.WriteLine($"Partially covered lines: {string.Join(",", partiallyCoveredLines)}");
        }