From 799794e544089ab56974ae9bea5ce2b3e720030b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Mon, 8 Mar 2021 13:02:26 +0100 Subject: [PATCH] bugfix --- src/coverlet.core/CoverageDetails.cs | 15 +++++++-------- src/coverlet.core/CoverageSummary.cs | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/coverlet.core/CoverageDetails.cs b/src/coverlet.core/CoverageDetails.cs index d7e0860b2..be2ccd4e2 100644 --- a/src/coverlet.core/CoverageDetails.cs +++ b/src/coverlet.core/CoverageDetails.cs @@ -5,20 +5,19 @@ namespace Coverlet.Core internal class CoverageDetails { private double _averageModulePercent; - private double _covered; - public double Covered + public Modules Modules { get; internal set; } + public double Covered { get; internal set; } + public int Total { get; internal set; } + public double Percent { - get => _covered; - internal set + get { - _covered = value; - Percent = Total == 0 ? 100D : Math.Floor((_covered / Total) * 10000) / 100; + if (Modules?.Count == 0) return 0; + return Total == 0 ? 100D : Math.Floor((Covered / Total) * 10000) / 100; } } - public int Total { get; internal set; } - public double Percent { get; internal set; } public double AverageModulePercent { get { return Math.Floor(_averageModulePercent * 100) / 100; } diff --git a/src/coverlet.core/CoverageSummary.cs b/src/coverlet.core/CoverageSummary.cs index 72346a060..9e3c74e83 100644 --- a/src/coverlet.core/CoverageSummary.cs +++ b/src/coverlet.core/CoverageSummary.cs @@ -52,7 +52,7 @@ public CoverageDetails CalculateLineCoverage(Documents documents) public CoverageDetails CalculateLineCoverage(Modules modules) { - var details = new CoverageDetails(); + var details = new CoverageDetails{Modules = modules}; var accumPercent = 0.0D; if (modules.Count == 0) @@ -155,7 +155,7 @@ public CoverageDetails CalculateBranchCoverage(Documents documents) public CoverageDetails CalculateBranchCoverage(Modules modules) { - var details = new CoverageDetails(); + var details = new CoverageDetails{ Modules = modules }; var accumPercent = 0.0D; if (modules.Count == 0) @@ -219,7 +219,7 @@ public CoverageDetails CalculateMethodCoverage(Documents documents) public CoverageDetails CalculateMethodCoverage(Modules modules) { - var details = new CoverageDetails(); + var details = new CoverageDetails{ Modules = modules }; var accumPercent = 0.0D; if (modules.Count == 0)