-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'finnnewick-justgiving-master'
- Loading branch information
Showing
11 changed files
with
125 additions
and
40 deletions.
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
32 changes: 32 additions & 0 deletions
32
PactNet.Tests/Reporters/Outputters/FileReportOutputterTests.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,32 @@ | ||
using System.Collections.Generic; | ||
using NSubstitute; | ||
using PactNet.Logging; | ||
using PactNet.Reporters; | ||
using PactNet.Reporters.Outputters; | ||
using Xunit; | ||
|
||
namespace PactNet.Tests.Reporters.Outputters | ||
{ | ||
public class FileReportOutputterTests | ||
{ | ||
private ILog _log; | ||
|
||
private IReportOutputter GetSubject() | ||
{ | ||
_log = Substitute.For<ILog>(); | ||
|
||
return new FileReportOutputter(() => _log); | ||
} | ||
|
||
[Fact] | ||
public void Write_WithReport_CallsDebugOnTheLoggerWithReport() | ||
{ | ||
const string report = "Hello!"; | ||
var outputter = GetSubject(); | ||
|
||
outputter.Write(report); | ||
|
||
_log.Received(1).Debug(report); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
using System.Collections.Generic; | ||
using PactNet.Reporters.Outputters; | ||
|
||
namespace PactNet | ||
{ | ||
public class PactVerifierConfig | ||
{ | ||
public string LogDir { get; set; } | ||
|
||
public IList<IReportOutputter> ReportOutputters { get; private set; } | ||
|
||
internal string LoggerName; | ||
|
||
public PactVerifierConfig() | ||
{ | ||
LogDir = Constants.DefaultLogDir; | ||
ReportOutputters = new List<IReportOutputter> | ||
{ | ||
new ConsoleReportOutputter(), | ||
new FileReportOutputter(() => LoggerName) | ||
}; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
using System; | ||
|
||
namespace PactNet.Reporters.Outputters | ||
{ | ||
internal class ConsoleReportOutputter : IReportOutputter | ||
{ | ||
public void Write(string report) | ||
{ | ||
Console.WriteLine(report); | ||
} | ||
} | ||
} |
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,25 @@ | ||
using System; | ||
using PactNet.Logging; | ||
|
||
namespace PactNet.Reporters.Outputters | ||
{ | ||
internal class FileReportOutputter : IReportOutputter | ||
{ | ||
private readonly Func<ILog> _logFactory; | ||
|
||
internal FileReportOutputter(Func<ILog> logFactory) | ||
{ | ||
_logFactory = logFactory; | ||
} | ||
|
||
public FileReportOutputter(Func<string> loggerNameGenerator) | ||
: this(() => LogProvider.GetLogger(loggerNameGenerator())) | ||
{ | ||
} | ||
|
||
public void Write(string report) | ||
{ | ||
_logFactory().Debug(report); | ||
} | ||
} | ||
} |
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,7 @@ | ||
namespace PactNet.Reporters.Outputters | ||
{ | ||
public interface IReportOutputter | ||
{ | ||
void Write(string report); | ||
} | ||
} |
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