@@ -25,17 +25,32 @@ public void ShouldProduceExpectedHtml()
2525 // resetting here explicitly
2626 Configurator . IdGenerator . Reset ( ) ;
2727
28- var model = new HtmlReportViewModel (
29- new DefaultHtmlReportConfiguration ( ) ,
30- new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
28+ // setting the culture to make sure the date is formatted the same on all machines
29+ using ( new TemporaryCulture ( "en-GB" ) )
30+ {
31+ var model = new HtmlReportViewModel (
32+ new DefaultHtmlReportConfiguration ( ) ,
33+ new ReportTestData ( ) . CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds ( ) ) ;
3134
32- var sut = new HtmlReportBuilder { DateProvider = ( ) => new DateTime ( 2014 , 3 , 25 , 11 , 30 , 5 ) } ;
35+ var sut = new HtmlReportBuilder { DateProvider = ( ) => new DateTime ( 2014 , 3 , 25 , 11 , 30 , 5 ) } ;
36+ var result = sut . CreateReport ( model ) ;
37+ Approvals . Verify ( result ) ;
38+ }
39+ }
40+ }
3341
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 ) ;
42+ public class TemporaryCulture : IDisposable
43+ {
44+ private readonly string _originalCulture ;
45+ public TemporaryCulture ( string newCulture )
46+ {
47+ _originalCulture = Thread . CurrentThread . CurrentCulture . Name ;
48+ Thread . CurrentThread . CurrentCulture = CultureInfo . CreateSpecificCulture ( newCulture ) ;
49+ }
50+
51+ public void Dispose ( )
52+ {
53+ Thread . CurrentThread . CurrentCulture = CultureInfo . CreateSpecificCulture ( _originalCulture ) ;
3954 }
4055 }
4156}
0 commit comments