-
-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
606 additions
and
241 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Cake.Common.Tests/Fixtures/Tools/DotCover/Report/DotCoverReporterFixture.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,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Cake.Common.Tools.DotCover.Report; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Core.IO; | ||
using NSubstitute; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Tools.DotCover.Report | ||
{ | ||
internal sealed class DotCoverReporterFixture : DotCoverFixture<DotCoverReportSettings> | ||
{ | ||
public FilePath SourceFile { get; set; } | ||
public FilePath OutputFile { get; set; } | ||
|
||
public DotCoverReporterFixture() | ||
{ | ||
// Set the source file. | ||
SourceFile = new FilePath("./result.dcvr"); | ||
|
||
// Setup the output file. | ||
OutputFile = new FilePath("./result.xml"); | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new DotCoverReporter(FileSystem, Environment, ProcessRunner, Tools); | ||
tool.Report(SourceFile, OutputFile, Settings); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/Cake.Common.Tests/Unit/Tools/DotCover/Report/DotCoverReporterTests.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,100 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Common.Tests.Fixtures.Tools.DotCover.Report; | ||
using Cake.Common.Tools.DotCover; | ||
using Cake.Common.Tools.NUnit; | ||
using Cake.Common.Tools.XUnit; | ||
using Cake.Core.IO; | ||
using Cake.Testing; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Tools.DotCover.Report | ||
{ | ||
public sealed class DotCoverReporterTests | ||
{ | ||
public sealed class TheReportMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Source_File_Is_Null() | ||
{ | ||
// Given | ||
var fixture = new DotCoverReporterFixture(); | ||
fixture.SourceFile = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
Assert.IsArgumentNullException(result, "sourceFile"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Output_File_Is_Null() | ||
{ | ||
// Given | ||
var fixture = new DotCoverReporterFixture(); | ||
fixture.OutputFile = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
Assert.IsArgumentNullException(result, "outputFile"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
var fixture = new DotCoverReporterFixture(); | ||
fixture.Settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
Assert.IsArgumentNullException(result, "settings"); | ||
} | ||
|
||
[Theory] | ||
[InlineData(DotCoverReportType.DetailedXML, "DetailedXML")] | ||
[InlineData(DotCoverReportType.HTML, "HTML")] | ||
[InlineData(DotCoverReportType.JSON, "JSON")] | ||
[InlineData(DotCoverReportType.NDependXML, "NDependXML")] | ||
public void Should_Append_ReportType(DotCoverReportType reportType, string reportTypeString) | ||
{ | ||
// Given | ||
var fixture = new DotCoverReporterFixture(); | ||
fixture.Settings.ReportType = reportType; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("Report " + | ||
"/Source=\"/Working/result.dcvr\" " + | ||
"/Output=\"/Working/result.xml\" " + | ||
"/ReportType=" + reportTypeString, result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Append_LogFile() | ||
{ | ||
// Given | ||
var fixture = new DotCoverReporterFixture(); | ||
fixture.Settings.LogFile = "./logfile.log"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("Report " + | ||
"/Source=\"/Working/result.dcvr\" " + | ||
"/Output=\"/Working/result.xml\" " + | ||
"/LogFile=\"/Working/logfile.log\"", result.Args); | ||
} | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.