1- namespace TestStack . ConventionTests . Internal
2- {
3- using System . Linq ;
4- using TestStack . ConventionTests . Reporting ;
5-
6- public static class Executor
7- {
8- public static ResultInfo GetConventionReport ( string conventionTitle , object [ ] failingData , IConventionData data )
9- {
10- data . EnsureHasNonEmptySource ( ) ;
11- var passed = failingData . None ( ) ;
12-
13- var conventionResult = new ResultInfo (
14- passed ? TestResult . Passed : TestResult . Failed ,
15- conventionTitle ,
16- data . Description ,
17- failingData . Select ( FormatData ) . ToArray ( ) ) ;
18- return conventionResult ;
19- }
20-
21- public static ResultInfo GetConventionReportWithApprovedExeptions ( string conventionTitle , object [ ] failingData , IConventionData data )
22- {
23- var conventionResult = Executor . GetConventionReport ( conventionTitle , failingData , data ) ;
24- var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
25- // Add approved exceptions to report
26- conventionReportTextRenderer . RenderItems ( conventionResult ) ;
27- conventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
28-
29- return conventionResult ;
30- }
31-
32- static ConventionReportFailure FormatData < T > ( T failingData )
33- {
34- var formatter = Convention . Formatters . FirstOrDefault ( f => f . CanFormat ( failingData ) ) ;
35-
36- if ( formatter == null )
37- throw new NoDataFormatterFoundException ( typeof ( T ) . Name + " has no formatter, add one with `Convention.Formatters.Add(new MyDataFormatter());`" ) ;
38-
39- return formatter . Format ( failingData ) ;
40- }
41- }
1+ namespace TestStack . ConventionTests . Internal
2+ {
3+ using System . Linq ;
4+ using TestStack . ConventionTests . Conventions ;
5+ using TestStack . ConventionTests . Reporting ;
6+
7+ public static class Executor
8+ {
9+ public static ResultInfo GetConventionReport ( string conventionTitle , object [ ] failingData , IConventionData data )
10+ {
11+ if ( ! data . HasData )
12+ throw new ConventionSourceInvalidException ( string . Format ( "{0} has no data" , data . Description ) ) ;
13+
14+ var passed = failingData . None ( ) ;
15+
16+ var conventionResult = new ResultInfo (
17+ passed ? TestResult . Passed : TestResult . Failed ,
18+ conventionTitle ,
19+ data . Description ,
20+ failingData . Select ( FormatData ) . ToArray ( ) ) ;
21+ return conventionResult ;
22+ }
23+
24+ public static ResultInfo GetConventionReportWithApprovedExeptions ( string conventionTitle , object [ ] failingData , IConventionData data )
25+ {
26+ var conventionResult = Executor . GetConventionReport ( conventionTitle , failingData , data ) ;
27+ var conventionReportTextRenderer = new ConventionReportTextRenderer ( ) ;
28+ // Add approved exceptions to report
29+ conventionReportTextRenderer . RenderItems ( conventionResult ) ;
30+ conventionResult . WithApprovedException ( conventionReportTextRenderer . Output ) ;
31+
32+ return conventionResult ;
33+ }
34+
35+ static ConventionReportFailure FormatData < T > ( T failingData )
36+ {
37+ var formatter = Convention . Formatters . FirstOrDefault ( f => f . CanFormat ( failingData ) ) ;
38+
39+ if ( formatter == null )
40+ throw new NoDataFormatterFoundException ( typeof ( T ) . Name + " has no formatter, add one with `Convention.Formatters.Add(new MyDataFormatter());`" ) ;
41+
42+ return formatter . Format ( failingData ) ;
43+ }
44+ }
4245}
0 commit comments