Skip to content

Commit 216ac1e

Browse files
committed
using ApproveResultsProcessor
1 parent ce23eb2 commit 216ac1e

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

TestStack.ConventionTests/Convention.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
using System.Collections.Generic;
55
using System.IO;
66
using System.Reflection;
7-
using ApprovalTests;
8-
using ApprovalTests.Core.Exceptions;
97
using TestStack.ConventionTests.Internal;
108
using TestStack.ConventionTests.Reporting;
119

@@ -35,7 +33,8 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
3533
Is(convention, data, new ThrowOnFailureResultsProcessor());
3634
}
3735

38-
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data, IResultsProcessor reporter)
36+
public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSource data,
37+
IResultsProcessor processor)
3938
where TDataSource : IConventionData
4039
{
4140
try
@@ -45,7 +44,7 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
4544
Reports.AddRange(conventionResult);
4645

4746
new ConventionReportTraceRenderer().Process(conventionResult);
48-
reporter.Process(conventionResult);
47+
processor.Process(conventionResult);
4948
}
5049
finally
5150
{
@@ -56,26 +55,7 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
5655
public static void IsWithApprovedExeptions<TDataSource>(IConvention<TDataSource> convention, TDataSource data)
5756
where TDataSource : IConventionData
5857
{
59-
var context = new ConventionContext(data.Description, Formatters);
60-
var conventionResult = context.Execute(convention, data);
61-
Reports.AddRange(conventionResult);
62-
63-
try
64-
{
65-
var conventionReportTextRenderer = new ConventionReportTextRenderer();
66-
conventionReportTextRenderer.Process(conventionResult);
67-
Approvals.Verify(conventionReportTextRenderer.Output);
68-
69-
new ConventionReportTraceRenderer().Process(conventionResult);
70-
}
71-
catch (ApprovalException ex)
72-
{
73-
throw new ConventionFailedException("Approved exceptions for convention differs\r\n\r\n"+ex.Message, ex);
74-
}
75-
finally
76-
{
77-
HtmlRenderer.Process(Reports.ToArray());
78-
}
58+
Is(convention, data, new ApproveResultsProcessor());
7959
}
8060

8161
// http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917

TestStack.ConventionTests/Reporting/ApproveResultsProcessor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace TestStack.ConventionTests.Reporting
22
{
3+
using System;
34
using ApprovalTests;
45
using ApprovalTests.Core.Exceptions;
56
using TestStack.ConventionTests.Internal;
@@ -16,7 +17,10 @@ public void Process(params ConventionResult[] results)
1617
}
1718
catch (ApprovalException ex)
1819
{
19-
throw new ConventionFailedException("Approved exceptions for convention differs\r\n\r\n" + ex.Message,
20+
throw new ConventionFailedException("Approved exceptions for convention differs" +
21+
Environment.NewLine +
22+
Environment.NewLine +
23+
ex.Message,
2024
ex);
2125
}
2226
}

0 commit comments

Comments
 (0)