11using System ;
2+ using System . Globalization ;
23using System . IO ;
34using System . Reflection ;
45using System . Runtime . CompilerServices ;
6+ using System . Text . RegularExpressions ;
7+ using System . Threading ;
58using ApprovalTests ;
69using ApprovalTests . Reporters ;
710using NUnit . Framework ;
11+ using TestStack . BDDfy . Configuration ;
812using TestStack . BDDfy . Reporters . Html ;
913
1014namespace TestStack . BDDfy . Tests . Reporters . Html
1115{
1216 [ TestFixture ]
13- [ UseReporter ( typeof ( DiffReporter ) ) ]
17+ [ UseReporter ( typeof ( DiffReporter ) ) ]
1418 public class HtmlReportBuilderTests
1519 {
1620 [ Test ]
1721 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
1822 public void ShouldProduceExpectedHtml ( )
1923 {
20- string expected = GetReportHtml ( ) ;
24+ // somehow the scenario id keeps increasing on TC
25+ // resetting here explicitly
26+ Configurator . IdGenerator . Reset ( ) ;
27+
2128 var model = new HtmlReportViewModel (
22- new DefaultHtmlReportConfiguration ( ) ,
29+ new DefaultHtmlReportConfiguration ( ) ,
2330 new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
24- var sut = new HtmlReportBuilder ( ) ;
25- sut . DateProvider = ( ) => new DateTime ( 2014 , 3 , 25 , 11 , 30 , 5 ) ;
2631
27- var result = sut . CreateReport ( model ) ;
32+ var sut = new HtmlReportBuilder { DateProvider = ( ) => new DateTime ( 2014 , 3 , 25 , 11 , 30 , 5 ) } ;
2833
29- //Approvals.Verify(result);
30- Assert . That ( result , Is . EqualTo ( expected ) ) ;
31- }
32-
33- private string GetReportHtml ( )
34- {
35- var assembly = Assembly . GetExecutingAssembly ( ) ;
36- var resourceName = "TestStack.BDDfy.Tests.Reporters.Html.HtmlReportBuilderTests.ShouldProduceExpectedHtml.approved.txt" ;
37-
38- string result ;
39- using ( Stream stream = assembly . GetManifestResourceStream ( resourceName ) )
40- {
41- using ( StreamReader reader = new StreamReader ( stream ) )
42- {
43- result = reader . ReadToEnd ( ) ;
44- }
45- }
46-
47- return result ;
34+ // setting the culture to make sure the date is formatted the same on all machines
35+ Thread . CurrentThread . CurrentCulture = new CultureInfo ( "en-GB" ) ;
36+
37+ var result = sut . CreateReport ( model ) ;
38+ Approvals . Verify ( result ) ;
4839 }
49-
5040 }
5141}
0 commit comments