@@ -9,35 +9,37 @@ namespace TestStack.BDDfy.Tests.Reporters.Html
99 [ TestFixture ]
1010 public class HtmlReporterTests
1111 {
12- private TestableHtmlReporter SUT ;
12+ private TestableHtmlReporter _sut ;
1313 private const string OutputPath = @"C:\Reports" ;
1414 private const string ReportData = "Report Data" ;
15- private const string ErrorMessage = "Error occurred." ;
15+ private const string CustomStylesheet = "some custom css in here!" ;
16+ private const string CustomJavascript = "some custom javascript in here!" ;
17+ private const string ErrorMessage = "There was some exception." ;
1618
1719 [ SetUp ]
1820 public void SetUp ( )
1921 {
20- SUT = TestableHtmlReporter . Create ( ) ;
22+ _sut = TestableHtmlReporter . Create ( ) ;
2123 }
2224
2325 [ Test ]
2426 public void ShouldCreateReportIfProcessingSucceeds ( )
2527 {
26- SUT . Builder . CreateReport ( Arg . Any < FileReportModel > ( ) ) . Returns ( ReportData ) ;
28+ _sut . Builder . CreateReport ( Arg . Any < FileReportModel > ( ) ) . Returns ( ReportData ) ;
2729
28- SUT . Process ( new List < Story > ( ) ) ;
30+ _sut . Process ( new List < Story > ( ) ) ;
2931
30- SUT . Writer . Received ( ) . OutputReport ( ReportData , Arg . Any < string > ( ) , Arg . Any < string > ( ) ) ;
32+ _sut . Writer . Received ( ) . OutputReport ( ReportData , Arg . Any < string > ( ) , Arg . Any < string > ( ) ) ;
3133 }
3234
3335 [ Test ]
3436 public void ShouldPrintErrorInReportIfProcessingFails ( )
3537 {
36- SUT . Builder . CreateReport ( Arg . Any < FileReportModel > ( ) ) . Returns ( x => { throw new Exception ( ErrorMessage ) ; } ) ;
38+ _sut . Builder . CreateReport ( Arg . Any < FileReportModel > ( ) ) . Returns ( x => { throw new Exception ( ErrorMessage ) ; } ) ;
3739
38- SUT . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
40+ _sut . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
3941
40- SUT . Writer . Received ( ) . OutputReport (
42+ _sut . Writer . Received ( ) . OutputReport (
4143 Arg . Is < string > ( s => s . StartsWith ( ErrorMessage ) ) ,
4244 Arg . Any < string > ( ) ,
4345 Arg . Any < string > ( ) ) ;
@@ -46,56 +48,55 @@ public void ShouldPrintErrorInReportIfProcessingFails()
4648 [ Test ]
4749 public void ShouldLoadCustomStyleSheetIfOneExists ( )
4850 {
49- const string customStylesheet = OutputPath + @"\BDDfyCustom.css" ;
50- SUT . Configuration . OutputPath . Returns ( OutputPath ) ;
51- SUT . FileReader . Exists ( customStylesheet ) . Returns ( true ) ;
52- SUT . FileReader . Read ( customStylesheet ) . Returns ( ReportData ) ;
51+ const string customStylesheetFilePath = OutputPath + @"\BDDfyCustom.css" ;
52+ _sut . Configuration . OutputPath . Returns ( OutputPath ) ;
53+ _sut . FileReader . Exists ( customStylesheetFilePath ) . Returns ( true ) ;
54+ _sut . FileReader . Read ( customStylesheetFilePath ) . Returns ( CustomStylesheet ) ;
5355
54- SUT . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
56+ _sut . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
5557
56- Assert . That ( SUT . Model . CustomStylesheet , Is . EqualTo ( ReportData ) ) ;
57- SUT . FileReader . Received ( ) . Read ( customStylesheet ) ;
58+ Assert . That ( _sut . Model . CustomStylesheet , Is . EqualTo ( CustomStylesheet ) ) ;
59+ _sut . FileReader . Received ( ) . Read ( customStylesheetFilePath ) ;
5860 }
5961
6062 [ Test ]
6163 public void ShouldNotLoadCustomStyleSheetIfNoneExist ( )
6264 {
6365 const string customStylesheet = OutputPath + @"\BDDfyCustom.css" ;
64- SUT . Configuration . OutputPath . Returns ( OutputPath ) ;
65- SUT . FileReader . Exists ( customStylesheet ) . Returns ( false ) ;
66+ _sut . Configuration . OutputPath . Returns ( OutputPath ) ;
67+ _sut . FileReader . Exists ( customStylesheet ) . Returns ( false ) ;
6668
67- SUT . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
69+ _sut . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
6870
69- Assert . That ( SUT . Model . CustomStylesheet , Is . Null ) ;
70- SUT . FileReader . DidNotReceive ( ) . Read ( customStylesheet ) ;
71+ Assert . That ( _sut . Model . CustomStylesheet , Is . Null ) ;
72+ _sut . FileReader . DidNotReceive ( ) . Read ( customStylesheet ) ;
7173 }
7274
7375 [ Test ]
7476 public void ShouldLoadCustomJavascriptIfOneExists ( )
7577 {
76- const string javaScript = OutputPath + @"\BDDfyCustom.js" ;
77- SUT . Configuration . OutputPath . Returns ( OutputPath ) ;
78- SUT . FileReader . Exists ( javaScript ) . Returns ( true ) ;
79- SUT . FileReader . Read ( javaScript ) . Returns ( ReportData ) ;
78+ const string javaScriptFilePath = OutputPath + @"\BDDfyCustom.js" ;
79+ _sut . Configuration . OutputPath . Returns ( OutputPath ) ;
80+ _sut . FileReader . Exists ( javaScriptFilePath ) . Returns ( true ) ;
81+ _sut . FileReader . Read ( javaScriptFilePath ) . Returns ( CustomJavascript ) ;
8082
81- SUT . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
83+ _sut . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
8284
83- Assert . That ( SUT . Model . CustomJavascript , Is . EqualTo ( ReportData ) ) ;
84- SUT . FileReader . Received ( ) . Read ( javaScript ) ;
85+ Assert . That ( _sut . Model . CustomJavascript , Is . EqualTo ( CustomJavascript ) ) ;
86+ _sut . FileReader . Received ( ) . Read ( javaScriptFilePath ) ;
8587 }
8688
8789 [ Test ]
8890 public void ShouldNotLoadCustomJavascriptIfNoneExist ( )
8991 {
9092 const string customJavascript = OutputPath + @"\BDDfyCustom.js" ;
91- SUT . Configuration . OutputPath . Returns ( OutputPath ) ;
92- SUT . FileReader . Exists ( customJavascript ) . Returns ( false ) ;
93+ _sut . Configuration . OutputPath . Returns ( OutputPath ) ;
94+ _sut . FileReader . Exists ( customJavascript ) . Returns ( false ) ;
9395
94- SUT . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
96+ _sut . Process ( new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
9597
96- Assert . That ( SUT . Model . CustomJavascript , Is . Null ) ;
97- SUT . FileReader . DidNotReceive ( ) . Read ( customJavascript ) ;
98+ Assert . That ( _sut . Model . CustomJavascript , Is . Null ) ;
99+ _sut . FileReader . DidNotReceive ( ) . Read ( customJavascript ) ;
98100 }
99-
100101 }
101102}
0 commit comments