Skip to content

Commit c466498

Browse files
committed
added ApproveResultsProcessor + some renames
1 parent 2c19bf9 commit c466498

8 files changed

+38
-13
lines changed

TestStack.ConventionTests/Convention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static Convention()
3232
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data)
3333
where TDataSource : IConventionData
3434
{
35-
Is(convention, data, new ConventionResultExceptionReporter());
35+
Is(convention, data, new ThrowOnFailureResultsProcessor());
3636
}
3737

3838
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data, IResultsProcessor reporter)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace TestStack.ConventionTests.Reporting
2+
{
3+
using ApprovalTests;
4+
using ApprovalTests.Core.Exceptions;
5+
using TestStack.ConventionTests.Internal;
6+
7+
public class ApproveResultsProcessor : IResultsProcessor
8+
{
9+
public void Process(params ConventionResult[] results)
10+
{
11+
try
12+
{
13+
var conventionReportTextRenderer = new ConventionReportTextRenderer();
14+
conventionReportTextRenderer.Process(results);
15+
Approvals.Verify(conventionReportTextRenderer.Output);
16+
}
17+
catch (ApprovalException ex)
18+
{
19+
throw new ConventionFailedException("Approved exceptions for convention differs\r\n\r\n" + ex.Message,
20+
ex);
21+
}
22+
}
23+
}
24+
}

TestStack.ConventionTests/Reporting/ConventionReportTextRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

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

12-
foreach (var conventionReport in conventionResult)
12+
foreach (var conventionReport in results)
1313
{
1414
var title = string.Format("{0}: '{1}' for '{2}'", conventionReport.Result, conventionReport.ConventionTitle,
1515
conventionReport.DataDescription);

TestStack.ConventionTests/Reporting/ConventionReportTraceRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

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

TestStack.ConventionTests/Reporting/HtmlReportRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public HtmlReportRenderer(string assemblyDirectory)
1414
file = Path.Combine(assemblyDirectory, "Conventions.htm");
1515
}
1616

17-
public void Process(params ConventionResult[] conventionResult)
17+
public void Process(params ConventionResult[] results)
1818
{
1919
var sb = new StringBuilder();
2020
var html = new HtmlTextWriter(new StringWriter(sb));
@@ -29,7 +29,7 @@ public void Process(params ConventionResult[] conventionResult)
2929
html.Write("Project Conventions");
3030
html.RenderEndTag();
3131

32-
foreach (var conventionReport in conventionResult)
32+
foreach (var conventionReport in results)
3333
{
3434
html.RenderBeginTag(HtmlTextWriterTag.P);
3535
html.RenderBeginTag(HtmlTextWriterTag.Div);

TestStack.ConventionTests/Reporting/IResultsProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
public interface IResultsProcessor
66
{
7-
void Process(params ConventionResult[] conventionResult);
7+
void Process(params ConventionResult[] results);
88
}
99
}

TestStack.ConventionTests/Reporting/ConventionResultExceptionReporter.cs renamed to TestStack.ConventionTests/Reporting/ThrowOnFailureResultsProcessor.cs

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

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

TestStack.ConventionTests/TestStack.ConventionTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@
6464
<Compile Include="Internal\ConventionContext.cs" />
6565
<Compile Include="Internal\ConventionResult.cs" />
6666
<Compile Include="Internal\NoDataFormatterFoundException.cs" />
67+
<Compile Include="Reporting\ApproveResultsProcessor.cs" />
6768
<Compile Include="Reporting\CsvReporter.cs" />
6869
<Compile Include="Reporting\DefaultFormatter.cs" />
6970
<Compile Include="Reporting\HtmlReportRenderer.cs" />
7071
<Compile Include="Reporting\ConventionReportTextRenderer.cs" />
7172
<Compile Include="Reporting\ConventionReportTraceRenderer.cs" />
72-
<Compile Include="Reporting\ConventionResultExceptionReporter.cs" />
73+
<Compile Include="Reporting\ThrowOnFailureResultsProcessor.cs" />
7374
<Compile Include="Conventions\ClassTypeHasSpecificNamespace.cs" />
7475
<Compile Include="Conventions\ConventionSourceInvalidException.cs" />
7576
<Compile Include="ConventionData\ProjectFile.cs" />

0 commit comments

Comments
 (0)