Skip to content

Commit 2c19bf9

Browse files
committed
converted IConventionReportRenderer to IResultsProcessor
This seems like a better abstraction, especially that some of them actually not render anything but approve/validate the results. This seems like a better abstraction not imposing any particular way the result should be handled
1 parent 0d8c73a commit 2c19bf9

File tree

9 files changed

+27
-35
lines changed

9 files changed

+27
-35
lines changed

TestStack.ConventionTests/Convention.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
3535
Is(convention, data, new ConventionResultExceptionReporter());
3636
}
3737

38-
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data, IConventionReportRenderer reporter)
38+
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data, IResultsProcessor reporter)
3939
where TDataSource : IConventionData
4040
{
4141
try
@@ -44,12 +44,12 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
4444
var conventionResult = context.GetConventionResults(convention, data);
4545
Reports.AddRange(conventionResult);
4646

47-
new ConventionReportTraceRenderer().Render(conventionResult);
48-
reporter.Render(conventionResult);
47+
new ConventionReportTraceRenderer().Process(conventionResult);
48+
reporter.Process(conventionResult);
4949
}
5050
finally
5151
{
52-
HtmlRenderer.Render(Reports.ToArray());
52+
HtmlRenderer.Process(Reports.ToArray());
5353
}
5454
}
5555

@@ -63,18 +63,18 @@ public static void IsWithApprovedExeptions<TDataSource>(IConvention<TDataSource>
6363
try
6464
{
6565
var conventionReportTextRenderer = new ConventionReportTextRenderer();
66-
conventionReportTextRenderer.Render(conventionResult);
66+
conventionReportTextRenderer.Process(conventionResult);
6767
Approvals.Verify(conventionReportTextRenderer.Output);
6868

69-
new ConventionReportTraceRenderer().Render(conventionResult);
69+
new ConventionReportTraceRenderer().Process(conventionResult);
7070
}
7171
catch (ApprovalException ex)
7272
{
7373
throw new ConventionFailedException("Approved exceptions for convention differs\r\n\r\n"+ex.Message, ex);
7474
}
7575
finally
7676
{
77-
HtmlRenderer.Render(Reports.ToArray());
77+
HtmlRenderer.Process(Reports.ToArray());
7878
}
7979
}
8080

TestStack.ConventionTests/Internal/IResultsProcessor.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

TestStack.ConventionTests/Reporting/ConventionReportTextRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using System.Text;
44
using TestStack.ConventionTests.Internal;
55

6-
public class ConventionReportTextRenderer : IConventionReportRenderer
6+
public class ConventionReportTextRenderer : IResultsProcessor
77
{
8-
public void Render(params ConventionResult[] conventionResult)
8+
public void Process(params ConventionResult[] conventionResult)
99
{
1010
var stringBuilder = new StringBuilder();
1111

TestStack.ConventionTests/Reporting/ConventionReportTraceRenderer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Diagnostics;
44
using TestStack.ConventionTests.Internal;
55

6-
public class ConventionReportTraceRenderer : IConventionReportRenderer
6+
public class ConventionReportTraceRenderer : IResultsProcessor
77
{
8-
public void Render(params ConventionResult[] conventionResult)
8+
public void Process(params ConventionResult[] conventionResult)
99
{
1010
var conventionReportTextRenderer = new ConventionReportTextRenderer();
11-
conventionReportTextRenderer.Render(conventionResult);
11+
conventionReportTextRenderer.Process(conventionResult);
1212
Trace.WriteLine(conventionReportTextRenderer.Output);
1313
}
1414
}

TestStack.ConventionTests/Reporting/ConventionResultExceptionReporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Linq;
44
using TestStack.ConventionTests.Internal;
55

6-
public class ConventionResultExceptionReporter : IConventionReportRenderer
6+
public class ConventionResultExceptionReporter : IResultsProcessor
77
{
8-
public void Render(params ConventionResult[] conventionResult)
8+
public void Process(params ConventionResult[] conventionResult)
99
{
1010
var conventionReportTextRenderer = new ConventionReportTextRenderer();
11-
conventionReportTextRenderer.Render(conventionResult);
11+
conventionReportTextRenderer.Process(conventionResult);
1212
if (conventionResult.Any(r => r.Result == TestResult.Failed))
1313
{
1414
throw new ConventionFailedException(conventionReportTextRenderer.Output);

TestStack.ConventionTests/Reporting/HtmlReportRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Web.UI;
66
using TestStack.ConventionTests.Internal;
77

8-
public class HtmlReportRenderer : IConventionReportRenderer
8+
public class HtmlReportRenderer : IResultsProcessor
99
{
1010
readonly string file;
1111

@@ -14,7 +14,7 @@ public HtmlReportRenderer(string assemblyDirectory)
1414
file = Path.Combine(assemblyDirectory, "Conventions.htm");
1515
}
1616

17-
public void Render(params ConventionResult[] conventionResult)
17+
public void Process(params ConventionResult[] conventionResult)
1818
{
1919
var sb = new StringBuilder();
2020
var html = new HtmlTextWriter(new StringWriter(sb));

TestStack.ConventionTests/Reporting/IConventionReportRenderer.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace TestStack.ConventionTests.Reporting
2+
{
3+
using TestStack.ConventionTests.Internal;
4+
5+
public interface IResultsProcessor
6+
{
7+
void Process(params ConventionResult[] conventionResult);
8+
}
9+
}

TestStack.ConventionTests/TestStack.ConventionTests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
<Compile Include="Internal\ConventionReportFailure.cs" />
6464
<Compile Include="Internal\ConventionContext.cs" />
6565
<Compile Include="Internal\ConventionResult.cs" />
66-
<Compile Include="Internal\IResultsProcessor.cs" />
6766
<Compile Include="Internal\NoDataFormatterFoundException.cs" />
6867
<Compile Include="Reporting\CsvReporter.cs" />
6968
<Compile Include="Reporting\DefaultFormatter.cs" />
@@ -81,7 +80,7 @@
8180
<Compile Include="Conventions\AllMethodsAreVirtual.cs" />
8281
<Compile Include="Conventions\AllClassesHaveDefaultConstructor.cs" />
8382
<Compile Include="Conventions\FilesAreEmbeddedResources.cs" />
84-
<Compile Include="Reporting\IConventionReportRenderer.cs" />
83+
<Compile Include="Reporting\IResultsProcessor.cs" />
8584
<Compile Include="Reporting\IReportDataFormatter.cs" />
8685
<Compile Include="Internal\AssemblyProjectLocator.cs" />
8786
<Compile Include="Convention.cs" />

0 commit comments

Comments
 (0)