-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/CoberturaConverter.Core.Tests/Regression/DotCoverTotalLinesValidAndCovered.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
using Xunit; | ||
|
||
namespace CoberturaConverter.Core.Tests.Regression | ||
{ | ||
public class DotCoverTotalLinesValidAndCovered | ||
{ | ||
// Issue #2 on GitHub reported the error that the CoberturaReport | ||
// used "CoveredStatements" instead of "TotalStatements" for the | ||
// "LinesValid" property in the destination Cobertura report | ||
|
||
[Fact] | ||
public void UseTotalStatementsForLinesValidInCobertura() | ||
{ | ||
using (var xmlStream = TestFilesFactory.GetTestFileStream(DotCoverConverter.Core.Tests.TestFile.DanglCommonDotCover)) | ||
{ | ||
using (var convertedCoberturaStream = CoberturaConverter.ConvertDotCoverToCobertura(xmlStream)) | ||
{ | ||
var coberturaXml = XDocument.Load(convertedCoberturaStream); | ||
|
||
var actualLinesValid = coberturaXml.Descendants() | ||
.Where(d => d.Name.LocalName == "coverage") | ||
.Select(d => d.Attribute("lines-valid")) | ||
.Select(a => a.Value) | ||
.Single(); | ||
|
||
var expected = "500"; // 500 TotalStatements in dotCover report | ||
Assert.Equal(expected, actualLinesValid); | ||
} | ||
} | ||
} | ||
|
||
[Fact] | ||
public void UseCoveredStatementsForLinesCoveredInCobertura() | ||
{ | ||
using (var xmlStream = TestFilesFactory.GetTestFileStream(DotCoverConverter.Core.Tests.TestFile.DanglCommonDotCover)) | ||
{ | ||
using (var convertedCoberturaStream = CoberturaConverter.ConvertDotCoverToCobertura(xmlStream)) | ||
{ | ||
var coberturaXml = XDocument.Load(convertedCoberturaStream); | ||
|
||
var actualLinesCovered = coberturaXml.Descendants() | ||
.Where(d => d.Name.LocalName == "coverage") | ||
.Select(d => d.Attribute("lines-covered")) | ||
.Select(a => a.Value) | ||
.Single(); | ||
|
||
var expected = "492"; // 500 TotalStatements in dotCover report | ||
Assert.Equal(expected, actualLinesCovered); | ||
} | ||
} | ||
} | ||
} | ||
} |