1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Globalization ;
3
4
using System . IO ;
4
5
using System . Linq ;
5
6
using System . Text ;
@@ -76,8 +77,8 @@ public string Report(CoverageResult result)
76
77
77
78
method . Add ( new XAttribute ( "cyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
78
79
method . Add ( new XAttribute ( "nPathComplexity" , "0" ) ) ;
79
- method . Add ( new XAttribute ( "sequenceCoverage" , methLineCoverage . Percent . ToString ( ) ) ) ;
80
- method . Add ( new XAttribute ( "branchCoverage" , methBranchCoverage . Percent . ToString ( ) ) ) ;
80
+ method . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( methLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
81
+ method . Add ( new XAttribute ( "branchCoverage" , Math . Round ( methBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
81
82
method . Add ( new XAttribute ( "isConstructor" , meth . Key . Contains ( "ctor" ) . ToString ( ) ) ) ;
82
83
method . Add ( new XAttribute ( "isGetter" , meth . Key . Contains ( "get_" ) . ToString ( ) ) ) ;
83
84
method . Add ( new XAttribute ( "isSetter" , meth . Key . Contains ( "set_" ) . ToString ( ) ) ) ;
@@ -157,8 +158,8 @@ public string Report(CoverageResult result)
157
158
methodSummary . Add ( new XAttribute ( "visitedSequencePoints" , methLineCoverage . Covered . ToString ( ) ) ) ;
158
159
methodSummary . Add ( new XAttribute ( "numBranchPoints" , methBranchCoverage . Total . ToString ( ) ) ) ;
159
160
methodSummary . Add ( new XAttribute ( "visitedBranchPoints" , methBranchCoverage . Covered . ToString ( ) ) ) ;
160
- methodSummary . Add ( new XAttribute ( "sequenceCoverage" , methLineCoverage . Percent . ToString ( ) ) ) ;
161
- methodSummary . Add ( new XAttribute ( "branchCoverage" , methBranchCoverage . Percent . ToString ( ) ) ) ;
161
+ methodSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( methLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
162
+ methodSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( methBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
162
163
methodSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
163
164
methodSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
164
165
methodSummary . Add ( new XAttribute ( "visitedClasses" , "0" ) ) ;
@@ -191,8 +192,8 @@ public string Report(CoverageResult result)
191
192
classSummary . Add ( new XAttribute ( "visitedSequencePoints" , classLineCoverage . Covered . ToString ( ) ) ) ;
192
193
classSummary . Add ( new XAttribute ( "numBranchPoints" , classBranchCoverage . Total . ToString ( ) ) ) ;
193
194
classSummary . Add ( new XAttribute ( "visitedBranchPoints" , classBranchCoverage . Covered . ToString ( ) ) ) ;
194
- classSummary . Add ( new XAttribute ( "sequenceCoverage" , classLineCoverage . Percent . ToString ( ) ) ) ;
195
- classSummary . Add ( new XAttribute ( "branchCoverage" , classBranchCoverage . Percent . ToString ( ) ) ) ;
195
+ classSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( classLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
196
+ classSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( classBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
196
197
classSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , classMaxCyclomaticComplexity . ToString ( ) ) ) ;
197
198
classSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , classMinCyclomaticComplexity . ToString ( ) ) ) ;
198
199
classSummary . Add ( new XAttribute ( "visitedClasses" , classVisited ? "1" : "0" ) ) ;
@@ -214,16 +215,16 @@ public string Report(CoverageResult result)
214
215
}
215
216
216
217
var moduleLineCoverage = summary . CalculateLineCoverage ( result . Modules ) ;
217
- var moduleBranchCoverage = summary . CalculateLineCoverage ( result . Modules ) ;
218
+ var moduleBranchCoverage = summary . CalculateBranchCoverage ( result . Modules ) ;
218
219
var moduleMaxCyclomaticComplexity = summary . CalculateMaxCyclomaticComplexity ( result . Modules ) ;
219
220
var moduleMinCyclomaticComplexity = summary . CalculateMinCyclomaticComplexity ( result . Modules ) ;
220
221
221
222
coverageSummary . Add ( new XAttribute ( "numSequencePoints" , moduleLineCoverage . Total . ToString ( ) ) ) ;
222
223
coverageSummary . Add ( new XAttribute ( "visitedSequencePoints" , moduleLineCoverage . Covered . ToString ( ) ) ) ;
223
224
coverageSummary . Add ( new XAttribute ( "numBranchPoints" , moduleBranchCoverage . Total . ToString ( ) ) ) ;
224
225
coverageSummary . Add ( new XAttribute ( "visitedBranchPoints" , moduleBranchCoverage . Covered . ToString ( ) ) ) ;
225
- coverageSummary . Add ( new XAttribute ( "sequenceCoverage" , moduleLineCoverage . Percent . ToString ( ) ) ) ;
226
- coverageSummary . Add ( new XAttribute ( "branchCoverage" , moduleBranchCoverage . Percent . ToString ( ) ) ) ;
226
+ coverageSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( moduleLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
227
+ coverageSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( moduleBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
227
228
coverageSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , moduleMaxCyclomaticComplexity . ToString ( ) ) ) ;
228
229
coverageSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , moduleMinCyclomaticComplexity . ToString ( ) ) ) ;
229
230
coverageSummary . Add ( new XAttribute ( "visitedClasses" , visitedClasses . ToString ( ) ) ) ;
0 commit comments