Exemple #1
0
        public ThresholdTypeFlags GetThresholdTypesBelowThreshold(CoverageSummary summary, Dictionary <ThresholdTypeFlags, double> thresholdTypeFlagValues, ThresholdStatistic thresholdStat)
        {
            var thresholdTypeFlags = ThresholdTypeFlags.None;

            switch (thresholdStat)
            {
            case ThresholdStatistic.Minimum:
            {
                if (!Modules.Any())
                {
                    thresholdTypeFlags = CompareThresholdValues(thresholdTypeFlagValues, thresholdTypeFlags, 0, 0, 0);
                }

                foreach (var module in Modules)
                {
                    double line   = summary.CalculateLineCoverage(module.Value).Percent;
                    double branch = summary.CalculateBranchCoverage(module.Value).Percent;
                    double method = summary.CalculateMethodCoverage(module.Value).Percent;

                    thresholdTypeFlags = CompareThresholdValues(thresholdTypeFlagValues, thresholdTypeFlags, line, branch, method);
                }
            }
            break;

            case ThresholdStatistic.Average:
            {
                double line   = summary.CalculateLineCoverage(Modules).AverageModulePercent;
                double branch = summary.CalculateBranchCoverage(Modules).AverageModulePercent;
                double method = summary.CalculateMethodCoverage(Modules).AverageModulePercent;

                thresholdTypeFlags = CompareThresholdValues(thresholdTypeFlagValues, thresholdTypeFlags, line, branch, method);
            }
            break;

            case ThresholdStatistic.Total:
            {
                double line   = summary.CalculateLineCoverage(Modules).Percent;
                double branch = summary.CalculateBranchCoverage(Modules).Percent;
                double method = summary.CalculateMethodCoverage(Modules).Percent;

                thresholdTypeFlags = CompareThresholdValues(thresholdTypeFlagValues, thresholdTypeFlags, line, branch, method);
            }
            break;
            }

            return(thresholdTypeFlags);
        }
Exemple #2
0
        public ThresholdTypeFlags GetThresholdTypesBelowThreshold(CoverageSummary summary, Dictionary <ThresholdTypeFlags, double> thresholdTypeFlagValues, ThresholdStatistic thresholdStat)
        {
            var thresholdTypeFlags = ThresholdTypeFlags.None;

            switch (thresholdStat)
            {
            case ThresholdStatistic.Minimum:
            {
                foreach (var module in Modules)
                {
                    double line   = summary.CalculateLineCoverage(module.Value).Percent;
                    double branch = summary.CalculateBranchCoverage(module.Value).Percent;
                    double method = summary.CalculateMethodCoverage(module.Value).Percent;

                    if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Line, out var lineThresholdValue) && lineThresholdValue > line)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Line;
                    }

                    if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Branch, out var branchThresholdValue) && branchThresholdValue > branch)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                    }

                    if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Method, out var methodThresholdValue) && methodThresholdValue > method)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Method;
                    }
                }
            }
            break;

            case ThresholdStatistic.Average:
            {
                double line   = summary.CalculateLineCoverage(Modules).AverageModulePercent;
                double branch = summary.CalculateBranchCoverage(Modules).AverageModulePercent;
                double method = summary.CalculateMethodCoverage(Modules).AverageModulePercent;

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Line, out var lineThresholdValue) && lineThresholdValue > line)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Line;
                }

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Branch, out var branchThresholdValue) && branchThresholdValue > branch)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                }

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Method, out var methodThresholdValue) && methodThresholdValue > method)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Method;
                }
            }
            break;

            case ThresholdStatistic.Total:
            {
                double line   = summary.CalculateLineCoverage(Modules).Percent;
                double branch = summary.CalculateBranchCoverage(Modules).Percent;
                double method = summary.CalculateMethodCoverage(Modules).Percent;

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Line, out var lineThresholdValue) && lineThresholdValue > line)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Line;
                }

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Branch, out var branchThresholdValue) && branchThresholdValue > branch)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                }

                if (thresholdTypeFlagValues.TryGetValue(ThresholdTypeFlags.Method, out var methodThresholdValue) && methodThresholdValue > method)
                {
                    thresholdTypeFlags |= ThresholdTypeFlags.Method;
                }
            }
            break;
            }

            return(thresholdTypeFlags);
        }
Exemple #3
0
        public ThresholdTypeFlags GetThresholdTypesBelowThreshold(CoverageSummary summary, double threshold, ThresholdTypeFlags thresholdTypes, ThresholdStatistic thresholdStat)
        {
            var thresholdTypeFlags = ThresholdTypeFlags.None;

            switch (thresholdStat)
            {
            case ThresholdStatistic.Minimum:
            {
                foreach (var module in Modules)
                {
                    var line   = summary.CalculateLineCoverage(module.Value).Percent * 100;
                    var branch = summary.CalculateBranchCoverage(module.Value).Percent * 100;
                    var method = summary.CalculateMethodCoverage(module.Value).Percent * 100;

                    if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                    {
                        if (line < threshold)
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Line;
                        }
                    }

                    if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                    {
                        if (branch < threshold)
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                        }
                    }

                    if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                    {
                        if (method < threshold)
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Method;
                        }
                    }
                }
            }
            break;

            case ThresholdStatistic.Average:
            {
                double line       = 0;
                double branch     = 0;
                double method     = 0;
                int    numModules = Modules.Count;

                foreach (var module in Modules)
                {
                    line   += summary.CalculateLineCoverage(module.Value).Percent * 100;
                    branch += summary.CalculateBranchCoverage(module.Value).Percent * 100;
                    method += summary.CalculateMethodCoverage(module.Value).Percent * 100;
                }

                if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                {
                    if ((line / numModules) < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Line;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                {
                    if ((branch / numModules) < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                {
                    if ((method / numModules) < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Method;
                    }
                }
            }
            break;

            case ThresholdStatistic.Total:
            {
                var line   = summary.CalculateLineCoverage(Modules).Percent * 100;
                var branch = summary.CalculateBranchCoverage(Modules).Percent * 100;
                var method = summary.CalculateMethodCoverage(Modules).Percent * 100;

                if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                {
                    if (line < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Line;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                {
                    if (branch < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                {
                    if (method < threshold)
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Method;
                    }
                }
            }
            break;
            }

            return(thresholdTypeFlags);
        }
        public ThresholdTypeFlags GetThresholdTypesBelowThreshold(CoverageSummary summary, Dictionary <ThresholdTypeFlags, double> thresholdTypeFlagValues, ThresholdTypeFlags thresholdTypes, ThresholdStatistic thresholdStat)
        {
            var thresholdTypeFlags = ThresholdTypeFlags.None;

            switch (thresholdStat)
            {
            case ThresholdStatistic.Minimum:
            {
                foreach (var module in Modules)
                {
                    double line   = summary.CalculateLineCoverage(module.Value).Percent;
                    double branch = summary.CalculateBranchCoverage(module.Value).Percent;
                    double method = summary.CalculateMethodCoverage(module.Value).Percent;

                    if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                    {
                        if (line < thresholdTypeFlagValues[ThresholdTypeFlags.Line])
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Line;
                        }
                    }

                    if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                    {
                        if (branch < thresholdTypeFlagValues[ThresholdTypeFlags.Branch])
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                        }
                    }

                    if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                    {
                        if (method < thresholdTypeFlagValues[ThresholdTypeFlags.Method])
                        {
                            thresholdTypeFlags |= ThresholdTypeFlags.Method;
                        }
                    }
                }
            }
            break;

            case ThresholdStatistic.Average:
            {
                double line   = summary.CalculateLineCoverage(Modules).AverageModulePercent;
                double branch = summary.CalculateBranchCoverage(Modules).AverageModulePercent;
                double method = summary.CalculateMethodCoverage(Modules).AverageModulePercent;

                if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                {
                    if ((line / numModules) < thresholdTypeFlagValues[ThresholdTypeFlags.Line])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Line;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                {
                    if ((branch / numModules) < thresholdTypeFlagValues[ThresholdTypeFlags.Branch])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                {
                    if ((method / numModules) < thresholdTypeFlagValues[ThresholdTypeFlags.Method])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Method;
                    }
                }
            }
            break;

            case ThresholdStatistic.Total:
            {
                double line   = summary.CalculateLineCoverage(Modules).Percent;
                double branch = summary.CalculateBranchCoverage(Modules).Percent;
                double method = summary.CalculateMethodCoverage(Modules).Percent;

                if ((thresholdTypes & ThresholdTypeFlags.Line) != ThresholdTypeFlags.None)
                {
                    if (line < thresholdTypeFlagValues[ThresholdTypeFlags.Line])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Line;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Branch) != ThresholdTypeFlags.None)
                {
                    if (branch < thresholdTypeFlagValues[ThresholdTypeFlags.Branch])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Branch;
                    }
                }

                if ((thresholdTypes & ThresholdTypeFlags.Method) != ThresholdTypeFlags.None)
                {
                    if (method < thresholdTypeFlagValues[ThresholdTypeFlags.Method])
                    {
                        thresholdTypeFlags |= ThresholdTypeFlags.Method;
                    }
                }
            }
            break;
            }

            return(thresholdTypeFlags);
        }