Files
Amaury Levé 03ff455578 Add editorconfig with tuned configuration (#1300)
Add editorconfig with tuned configuration
2022-02-14 09:14:38 +01:00

53 lines
2.9 KiB
C#

// Copyright (c) Toni Solarin-Sodara
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
using Coverlet.Core.Abstractions;
using Coverlet.MSbuild.Tasks;
using Moq;
using Xunit;
namespace Coverlet.Core.Reporters.Tests
{
public class Reporters
{
// we use lcov with extension .info and cobertura with extension .cobertura.xml
// to have all possible extension format
// empty coverletOutput is not possible thank's to props default
[Theory]
// single tfm
[InlineData("", "/folder/reportFolder/", "lcov", "/folder/reportFolder/coverage.info")]
[InlineData(null, "/folder/reportFolder/", "cobertura", "/folder/reportFolder/coverage.cobertura.xml")]
[InlineData(null, "/folder/reportFolder/file.ext", "cobertura", "/folder/reportFolder/file.ext")]
[InlineData(null, "/folder/reportFolder/file.ext1.ext2", "cobertura", "/folder/reportFolder/file.ext1.ext2")]
[InlineData(null, "/folder/reportFolder/file", "cobertura", "/folder/reportFolder/file.cobertura.xml")]
[InlineData(null, "file", "cobertura", "file.cobertura.xml")]
// multiple tfm
[InlineData("netcoreapp2.2", "/folder/reportFolder/", "lcov", "/folder/reportFolder/coverage.netcoreapp2.2.info")]
[InlineData("netcoreapp2.2", "/folder/reportFolder/", "cobertura", "/folder/reportFolder/coverage.netcoreapp2.2.cobertura.xml")]
[InlineData("net472", "/folder/reportFolder/file.ext", "cobertura", "/folder/reportFolder/file.net472.ext")]
[InlineData("net472", "/folder/reportFolder/file.ext1.ext2", "cobertura", "/folder/reportFolder/file.ext1.net472.ext2")]
[InlineData("netcoreapp2.2", "/folder/reportFolder/file", "cobertura", "/folder/reportFolder/file.netcoreapp2.2.cobertura.xml")]
[InlineData("netcoreapp2.2", "file", "cobertura", "file.netcoreapp2.2.cobertura.xml")]
public void Msbuild_ReportWriter(string coverletMultiTargetFrameworksCurrentTFM, string coverletOutput, string reportFormat, string expectedFileName)
{
var fileSystem = new Mock<IFileSystem>();
var console = new Mock<IConsole>();
var reportWriter = new ReportWriter(
coverletMultiTargetFrameworksCurrentTFM,
// mimic code inside CoverageResultTask.cs
Path.GetDirectoryName(coverletOutput),
coverletOutput,
new ReporterFactory(reportFormat).CreateReporter(),
fileSystem.Object,
console.Object,
new CoverageResult() { Modules = new Modules(), Parameters = new CoverageParameters() }, null);
string path = reportWriter.WriteReport();
// Path.Combine depends on OS so we can change only win side to avoid duplication
Assert.Equal(path.Replace('/', Path.DirectorySeparatorChar), expectedFileName.Replace('/', Path.DirectorySeparatorChar));
}
}
}