public CodeCoverageTracer(List <CodeCoveragePoint> points)
        {
            _debug     = Environment.GetEnvironmentVariable("PESTER_CC_DEBUG") == "1";
            _debugFile = Environment.GetEnvironmentVariable("PESTER_CC_DEBUG_FILE") ?? "CoverageTestFile";
            foreach (var point in points)
            {
                var key = $"{point.Line}:{point.Column}";
                if (!Hits.ContainsKey(point.Path))
                {
                    var lineColumn = new Dictionary <string, List <CodeCoveragePoint> > (StringComparer.OrdinalIgnoreCase)
                    {
                        [key] = new List <CodeCoveragePoint> {
                            point
                        }
                    };
                    Hits.Add(point.Path, lineColumn);
                    continue;
                }

                var hits = Hits[point.Path];
                if (!hits.ContainsKey(key))
                {
                    hits.Add(key, new List <CodeCoveragePoint> {
                        point
                    });
                    continue;
                }
                else
                {
                    var pointsOnLineAndColumn = hits[key];
                    pointsOnLineAndColumn.Add(point);
                }
            }
        }
Example #2
0
 public int GetHits(int priority)
 {
     if (priority > LargestPriority)
     {
         return(-1);
     }
     if (!Hits.ContainsKey(priority))
     {
         return(0);
     }
     return(Hits[priority]);
 }
Example #3
0
        public void AddHit(int priority)
        {
            if (!Hits.ContainsKey(priority))
            {
                Hits[priority] = 1;
            }
            else
            {
                Hits[priority]++;
            }

            if (priority > LargestPriority)
            {
                LargestPriority = priority;
            }
        }