@@ -29,7 +29,7 @@ static Convention()
29
29
}
30
30
31
31
public static IEnumerable < ResultInfo > ConventionReports { get { return Reports ; } }
32
- public static IList < IReportDataFormatter > Formatters { get ; private set ; }
32
+ public static IList < IReportDataFormatter > Formatters { get ; set ; }
33
33
34
34
public static void Is < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
35
35
where TDataSource : IConventionData
@@ -42,8 +42,7 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
42
42
{
43
43
try
44
44
{
45
- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
46
-
45
+ var conventionResult = Executor . GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
47
46
Reports . Add ( conventionResult ) ;
48
47
49
48
new ConventionReportTraceRenderer ( ) . Render ( conventionResult ) ;
@@ -58,15 +57,12 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
58
57
public static void IsWithApprovedExeptions < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
59
58
where TDataSource : IConventionData
60
59
{
61
- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
60
+ var conventionResult = Executor . GetConventionReportWithApprovedExeptions ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
62
61
Reports . Add ( conventionResult ) ;
63
62
64
63
try
65
64
{
66
65
var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
67
- conventionReportTextRenderer . RenderItems ( conventionResult ) ;
68
- conventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
69
-
70
66
conventionReportTextRenderer . Render ( conventionResult ) ;
71
67
Approvals . Verify ( conventionReportTextRenderer . Output ) ;
72
68
@@ -93,8 +89,8 @@ public static void Is<TDataSource>(ISymmetricConvention<TDataSource> convention,
93
89
{
94
90
try
95
91
{
96
- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
97
- var inverseConventionResult = GetConventionReport ( convention . InverseTitle , convention . GetFailingInverseData ( data ) . ToArray ( ) , data ) ;
92
+ var conventionResult = Executor . GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
93
+ var inverseConventionResult = Executor . GetConventionReport ( convention . InverseTitle , convention . GetFailingInverseData ( data ) . ToArray ( ) , data ) ;
98
94
99
95
Reports . Add ( conventionResult ) ;
100
96
Reports . Add ( inverseConventionResult ) ;
@@ -111,26 +107,18 @@ public static void Is<TDataSource>(ISymmetricConvention<TDataSource> convention,
111
107
public static void IsWithApprovedExeptions < TDataSource > ( ISymmetricConvention < TDataSource > convention , TDataSource data )
112
108
where TDataSource : IConventionData
113
109
{
114
- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
115
- var inverseConventionResult = GetConventionReport ( convention . InverseTitle , convention . GetFailingInverseData ( data ) . ToArray ( ) , data ) ;
110
+ var conventionResult = Executor . GetConventionReportWithApprovedExeptions ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
111
+ var inverseConventionResult = Executor . GetConventionReportWithApprovedExeptions ( convention . InverseTitle , convention . GetFailingInverseData ( data ) . ToArray ( ) , data ) ;
116
112
Reports . Add ( conventionResult ) ;
117
113
Reports . Add ( inverseConventionResult ) ;
118
114
119
115
try
120
116
{
121
- var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
122
- // Add approved exceptions to report
123
- conventionReportTextRenderer . RenderItems ( conventionResult ) ;
124
- conventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
125
-
126
- // Add approved exceptions to inverse report
127
- conventionReportTextRenderer . RenderItems ( inverseConventionResult ) ;
128
- inverseConventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
129
-
130
117
//Render both, with approved exceptions included
118
+ var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
131
119
conventionReportTextRenderer . Render ( conventionResult , inverseConventionResult ) ;
132
120
Approvals . Verify ( conventionReportTextRenderer . Output ) ;
133
-
121
+
134
122
// Trace on success
135
123
new ConventionReportTraceRenderer ( ) . Render ( conventionResult , inverseConventionResult ) ;
136
124
}
@@ -144,30 +132,6 @@ public static void IsWithApprovedExeptions<TDataSource>(ISymmetricConvention<TDa
144
132
}
145
133
}
146
134
147
- static ResultInfo GetConventionReport < TDataSource , TDataType > ( string conventionTitle , TDataType [ ] failingData , TDataSource data )
148
- where TDataSource : IConventionData
149
- {
150
- data . EnsureHasNonEmptySource ( ) ;
151
- var passed = failingData . None ( ) ;
152
-
153
- var conventionResult = new ResultInfo (
154
- passed ? TestResult . Passed : TestResult . Failed ,
155
- conventionTitle ,
156
- data . Description ,
157
- failingData . Select ( FormatData ) . ToArray ( ) ) ;
158
- return conventionResult ;
159
- }
160
-
161
- static ConventionReportFailure FormatData < T > ( T failingData )
162
- {
163
- var formatter = Formatters . FirstOrDefault ( f => f . CanFormat ( failingData ) ) ;
164
-
165
- if ( formatter == null )
166
- throw new NoDataFormatterFoundException ( typeof ( T ) . Name + " has no formatter, add one with `Convention.Formatters.Add(new MyDataFormatter());`" ) ;
167
-
168
- return formatter . Format ( failingData ) ;
169
- }
170
-
171
135
// http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917
172
136
static string AssemblyDirectory
173
137
{
0 commit comments