@@ -29,7 +29,7 @@ static Convention()
2929 }
3030
3131 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 ; }
3333
3434 public static void Is < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
3535 where TDataSource : IConventionData
@@ -42,8 +42,7 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
4242 {
4343 try
4444 {
45- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
46-
45+ var conventionResult = Executor . GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
4746 Reports . Add ( conventionResult ) ;
4847
4948 new ConventionReportTraceRenderer ( ) . Render ( conventionResult ) ;
@@ -58,15 +57,12 @@ public static void Is<TDataSource>(IConvention<TDataSource> convention, TDataSou
5857 public static void IsWithApprovedExeptions < TDataSource > ( IConvention < TDataSource > convention , TDataSource data )
5958 where TDataSource : IConventionData
6059 {
61- var conventionResult = GetConventionReport ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
60+ var conventionResult = Executor . GetConventionReportWithApprovedExeptions ( convention . ConventionTitle , convention . GetFailingData ( data ) . ToArray ( ) , data ) ;
6261 Reports . Add ( conventionResult ) ;
6362
6463 try
6564 {
6665 var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
67- conventionReportTextRenderer . RenderItems ( conventionResult ) ;
68- conventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
69-
7066 conventionReportTextRenderer . Render ( conventionResult ) ;
7167 Approvals . Verify ( conventionReportTextRenderer . Output ) ;
7268
@@ -93,8 +89,8 @@ public static void Is<TDataSource>(ISymmetricConvention<TDataSource> convention,
9389 {
9490 try
9591 {
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 ) ;
9894
9995 Reports . Add ( conventionResult ) ;
10096 Reports . Add ( inverseConventionResult ) ;
@@ -111,26 +107,18 @@ public static void Is<TDataSource>(ISymmetricConvention<TDataSource> convention,
111107 public static void IsWithApprovedExeptions < TDataSource > ( ISymmetricConvention < TDataSource > convention , TDataSource data )
112108 where TDataSource : IConventionData
113109 {
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 ) ;
116112 Reports . Add ( conventionResult ) ;
117113 Reports . Add ( inverseConventionResult ) ;
118114
119115 try
120116 {
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-
130117 //Render both, with approved exceptions included
118+ var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
131119 conventionReportTextRenderer . Render ( conventionResult , inverseConventionResult ) ;
132120 Approvals . Verify ( conventionReportTextRenderer . Output ) ;
133-
121+
134122 // Trace on success
135123 new ConventionReportTraceRenderer ( ) . Render ( conventionResult , inverseConventionResult ) ;
136124 }
@@ -144,30 +132,6 @@ public static void IsWithApprovedExeptions<TDataSource>(ISymmetricConvention<TDa
144132 }
145133 }
146134
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-
171135 // http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917
172136 static string AssemblyDirectory
173137 {
0 commit comments