Skip to content

Commit 7e8364c

Browse files
committed
got the html report's approval test working
1 parent 40bf80d commit 7e8364c

4 files changed

Lines changed: 19 additions & 29 deletions

File tree

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@
1717

1818
# Denote all files that are truly binary and should not be modified.
1919
*.exe binary
20-
*.dll binary
21-
*.approved.* binary
20+
*.dll binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ obj/
88
*.swp
99
*.orig
1010
*.nupkg
11+
*.received.txt
1112
*.crunchproject.local.xml
1213
*.crunchsolution.local.xml
1314
*.cache
Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
11
using System;
2+
using System.Globalization;
23
using System.IO;
34
using System.Reflection;
45
using System.Runtime.CompilerServices;
6+
using System.Text.RegularExpressions;
7+
using System.Threading;
58
using ApprovalTests;
69
using ApprovalTests.Reporters;
710
using NUnit.Framework;
11+
using TestStack.BDDfy.Configuration;
812
using TestStack.BDDfy.Reporters.Html;
913

1014
namespace 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
}

TestStack.BDDfy.Tests/Reporters/MarkDown/MarkDownReportBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void GivenAMarkDownReportBuilder()
1919
_sut = new MarkDownReportBuilder();
2020
}
2121

22-
public void AndGivenTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds()
22+
public void AndGivenTwoStoriesEachWithTwoScenariosWithThreeSteps()
2323
{
2424
_stories = new ReportTestData().CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds();
2525
}

0 commit comments

Comments
 (0)