Skip to content

Commit 99056d7

Browse files
committed
Added RunDate to FileReportModel
1 parent 4184833 commit 99056d7

8 files changed

Lines changed: 16 additions & 31 deletions

File tree

TestStack.BDDfy.Tests/Reporters/Html/HtmlReportBuilderTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
2-
using System.IO;
3-
using System.Reflection;
42
using System.Runtime.CompilerServices;
5-
using System.Text.RegularExpressions;
63
using ApprovalTests;
74
using ApprovalTests.Reporters;
85
using NUnit.Framework;
@@ -29,8 +26,9 @@ public void ShouldProduceExpectedHtml()
2926
var model = new HtmlReportViewModel(
3027
new DefaultHtmlReportConfiguration(),
3128
new ReportTestData().CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds());
29+
model.RunDate = new DateTime(2014, 3, 25, 11, 30, 5);
3230

33-
var sut = new HtmlReportBuilder {DateProvider = () => new DateTime(2014, 3, 25, 11, 30, 5)};
31+
var sut = new HtmlReportBuilder();
3432
var result = sut.CreateReport(model);
3533
Approvals.Verify(result);
3634
}

TestStack.BDDfy.Tests/Reporters/HtmlMetro/HtmlMetroReportBuilderTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public void ShouldProduceExpectedHtml()
2828
var model = new HtmlReportViewModel(
2929
new DefaultHtmlReportConfiguration(),
3030
new ReportTestData().CreateMixContainingEachTypeOfOutcome());
31+
model.RunDate = new DateTime(2014, 3, 25, 11, 30, 5);
3132

32-
var sut = new HtmlMetroReportBuilder {DateProvider = () => new DateTime(2014, 3, 25, 11, 30, 5)};
33+
var sut = new HtmlMetroReportBuilder();
3334
var result = sut.CreateReport(model);
3435
Approvals.Verify(result);
3536
}

TestStack.BDDfy/Reporters/FileReportModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34

45
namespace TestStack.BDDfy.Reporters
@@ -9,10 +10,12 @@ public FileReportModel(IEnumerable<Story> stories)
910
{
1011
_stories = stories;
1112
Summary = new FileReportSummaryModel(stories);
13+
RunDate = DateTime.Now;
1214
}
1315

1416
readonly IEnumerable<Story> _stories;
1517
public FileReportSummaryModel Summary { get; private set; }
18+
public DateTime RunDate { get; set; }
1619

1720
public IEnumerable<Story> Stories
1821
{

TestStack.BDDfy/Reporters/Html/HtmlReportBuilder.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace TestStack.BDDfy.Reporters.Html
66
{
77
public class HtmlReportBuilder : IReportBuilder
88
{
9-
private Func<DateTime> _dateProvider = () => DateTime.Now;
109
private HtmlReportViewModel _viewModel;
1110
readonly StringBuilder _html;
1211
const int TabIndentation = 2;
@@ -43,7 +42,7 @@ private void HtmlHead()
4342
EmbedCssFile(HtmlReportResources.BDDfy_css_min);
4443
EmbedCssFile(_viewModel.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
4544

46-
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", DateProvider().ToShortDateString()));
45+
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _viewModel.RunDate.ToShortDateString()));
4746
}
4847
}
4948

@@ -129,7 +128,7 @@ private void ResultDetails()
129128
}
130129
}
131130

132-
AddLine(string.Format("<p><span>Tested at: {0}</span></p>", _dateProvider()));
131+
AddLine(string.Format("<p><span>Tested at: {0}</span></p>", _viewModel.RunDate));
133132
}
134133
}
135134

@@ -296,11 +295,5 @@ private void AddHtmlComment(string htmlComment)
296295
_html.AppendFormat("/*{0}*/", htmlComment);
297296
_html.AppendLine();
298297
}
299-
300-
public Func<DateTime> DateProvider
301-
{
302-
get { return _dateProvider; }
303-
set { _dateProvider = value; }
304-
}
305298
}
306299
}

TestStack.BDDfy/Reporters/HtmlMetro/HtmlMetroReportBuilder.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,14 @@ namespace TestStack.BDDfy.Reporters.HtmlMetro
55
{
66
public class HtmlMetroReportBuilder : IReportBuilder
77
{
8-
private Func<DateTime> _dateProvider = () => DateTime.Now;
9-
108
string IReportBuilder.CreateReport(FileReportModel model)
119
{
1210
return CreateReport(model as HtmlReportViewModel);
1311
}
1412

1513
public string CreateReport(HtmlReportViewModel model)
1614
{
17-
return new MetroHtmlReportTemplate(model, DateProvider()).TransformText();
15+
return new MetroHtmlReportTemplate(model).TransformText();
1816
}
19-
20-
public Func<DateTime> DateProvider
21-
{
22-
get { return _dateProvider; }
23-
set { _dateProvider = value; }
24-
}
2517
}
2618
}

TestStack.BDDfy/Reporters/HtmlMetro/MetroHtmlReportTemplate.Model.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ namespace TestStack.BDDfy.Reporters.HtmlMetro
1111
partial class MetroHtmlReportTemplate
1212
{
1313
private readonly HtmlReportViewModel _model;
14-
public DateTime RunDate { get; set; }
1514

16-
public MetroHtmlReportTemplate(HtmlReportViewModel model, DateTime runDate)
15+
public MetroHtmlReportTemplate(HtmlReportViewModel model)
1716
{
1817
_model = model;
19-
RunDate = runDate;
2018
}
2119

2220
public HtmlReportViewModel Model

TestStack.BDDfy/Reporters/HtmlMetro/MetroHtmlReportTemplate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public virtual string TransformText()
5555
" rel=\'stylesheet\' type=\'text/css\'>\r\n\t\t<title>BDDfy Test Result ");
5656

5757
#line 18 "D:\Apps\github\TestStack.BDDfy\TestStack.BDDfy\Reporters\HtmlMetro\MetroHtmlReportTemplate.tt"
58-
this.Write(this.ToStringHelper.ToStringWithCulture(RunDate.ToShortDateString()));
58+
this.Write(this.ToStringHelper.ToStringWithCulture(Model.RunDate.ToShortDateString()));
5959

6060
#line default
6161
#line hidden
@@ -468,7 +468,7 @@ public virtual string TransformText()
468468
this.Write("\r\n\t\t\t\t</ul>\r\n\t\t\t</section>\r\n \r\n\t\t\t<section>\r\n\t\t\t\t<p>Tested at: ");
469469

470470
#line 172 "D:\Apps\github\TestStack.BDDfy\TestStack.BDDfy\Reporters\HtmlMetro\MetroHtmlReportTemplate.tt"
471-
this.Write(this.ToStringHelper.ToStringWithCulture(RunDate));
471+
this.Write(this.ToStringHelper.ToStringWithCulture(Model.RunDate));
472472

473473
#line default
474474
#line hidden

TestStack.BDDfy/Reporters/HtmlMetro/MetroHtmlReportTemplate.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<#= Model.CustomStylesheet ?? "" #>
1616
</style>
1717
<link href='http://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>
18-
<title>BDDfy Test Result <#= RunDate.ToShortDateString() #></title>
18+
<title>BDDfy Test Result <#= Model.RunDate.ToShortDateString() #></title>
1919
</head>
2020
<body>
2121
<div id='main'>
@@ -169,7 +169,7 @@ else
169169
</section>
170170

171171
<section>
172-
<p>Tested at: <#= RunDate #></p>
172+
<p>Tested at: <#= Model.RunDate #></p>
173173
<p>Powered by <a href='https://github.com/TestStack/TestStack.BDDfy'>BDDfy</a></p>
174174
</section>
175175

0 commit comments

Comments
 (0)