Skip to content

Commit faaa40f

Browse files
committed
starting to refactor formatters.
step one - removing static dependency
1 parent abebf0e commit faaa40f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

TestStack.ConventionTests/Internal/ConventionResult.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ public class ConventionResult : IConventionResult
99
{
1010
readonly List<ResultInfo> conventionResults;
1111
readonly string dataDescription;
12+
readonly IList<IReportDataFormatter> formatters;
1213

13-
public ConventionResult(string dataDescription)
14+
public ConventionResult(string dataDescription, IList<IReportDataFormatter> formatters)
1415
{
16+
this.formatters = formatters;
1517
this.dataDescription = dataDescription;
1618
conventionResults = new List<ResultInfo>();
1719
}
@@ -62,10 +64,9 @@ public void IsSymmetric<TResult>(
6264
secondSetFailureTitle, secondSetFailingData);
6365
}
6466

65-
static ConventionReportFailure FormatData<T>(T failingData)
67+
ConventionReportFailure FormatData<T>(T failingData)
6668
{
67-
var formatter = Convention.Formatters.FirstOrDefault(f => f.CanFormat(failingData));
68-
69+
var formatter = formatters.FirstOrDefault(f => f.CanFormat(failingData));
6970
if (formatter == null)
7071
{
7172
throw new NoDataFormatterFoundException(

TestStack.ConventionTests/Internal/Executor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static ResultInfo[] GetConventionResults<TDataSource>(IConvention<TDataSo
1111
if (!data.HasData)
1212
throw new ConventionSourceInvalidException(string.Format("{0} has no data", data.Description));
1313

14-
var resultGatherer = new ConventionResult(data.Description);
14+
var resultGatherer = new ConventionResult(data.Description, Convention.Formatters);
1515
convention.Execute(data, resultGatherer);
1616

1717
return resultGatherer.ConventionResults;
@@ -26,7 +26,7 @@ public static ResultInfo[] GetConventionResultsWithApprovedExeptions<TDataSource
2626
if (!data.HasData)
2727
throw new ConventionSourceInvalidException(string.Format("{0} has no data", data.Description));
2828

29-
var resultGatherer = new ConventionResult(data.Description);
29+
var resultGatherer = new ConventionResult(data.Description, Convention.Formatters);
3030
convention.Execute(data, resultGatherer);
3131
foreach (var conventionResult in resultGatherer.ConventionResults)
3232
{

0 commit comments

Comments
 (0)