10
10
public static class Convention
11
11
{
12
12
static readonly HtmlReportRenderer HtmlRenderer = new HtmlReportRenderer ( AssemblyDirectory ) ;
13
- static readonly List < ConventionResult > Reports = new List < ConventionResult > ( ) ;
14
13
15
14
static Convention ( )
16
15
{
@@ -24,38 +23,41 @@ static Convention()
24
23
} ;
25
24
}
26
25
27
- public static IEnumerable < ConventionResult > ConventionReports { get { return Reports ; } }
28
- public static IList < IReportDataFormatter > Formatters { get ; set ; }
26
+ public static IList < IReportDataFormatter > Formatters { get ; set ; }
29
27
30
28
public static void Is < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
31
29
where TDataSource : IConventionData
32
30
{
33
- Is ( convention , data , new ThrowOnFailureResultsProcessor ( ) ) ;
31
+ Is ( convention , data , new IResultsProcessor [ ]
32
+ {
33
+ HtmlRenderer ,
34
+ new ConventionReportTraceRenderer ( ) ,
35
+ new ThrowOnFailureResultsProcessor ( )
36
+ } ) ;
34
37
}
35
38
36
39
public static void Is < TDataSource > ( IConvention < TDataSource > convention , TDataSource data ,
37
- IResultsProcessor processor )
40
+ IResultsProcessor [ ] processors )
38
41
where TDataSource : IConventionData
39
42
{
40
- try
41
- {
42
- var context = new ConventionContext ( data . Description , Formatters ) ;
43
- var conventionResult = context . Execute ( convention , data ) ;
44
- Reports . AddRange ( conventionResult ) ;
43
+ var context = new ConventionContext ( data . Description , Formatters ) ;
44
+ var conventionResult = context . Execute ( convention , data ) ;
45
45
46
- new ConventionReportTraceRenderer ( ) . Process ( conventionResult ) ;
47
- processor . Process ( conventionResult ) ;
48
- }
49
- finally
46
+ foreach ( var processor in processors )
50
47
{
51
- HtmlRenderer . Process ( Reports . ToArray ( ) ) ;
48
+ processor . Process ( conventionResult ) ;
52
49
}
53
50
}
54
51
55
52
public static void IsWithApprovedExeptions < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
56
53
where TDataSource : IConventionData
57
54
{
58
- Is ( convention , data , new ApproveResultsProcessor ( ) ) ;
55
+ Is ( convention , data , new IResultsProcessor [ ]
56
+ {
57
+ HtmlRenderer ,
58
+ new ConventionReportTraceRenderer ( ) ,
59
+ new ApproveResultsProcessor ( )
60
+ } ) ;
59
61
}
60
62
61
63
// http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917
0 commit comments