Skip to content

Commit d8bbfbf

Browse files
committed
got existing tests passing with ReportModel
1 parent 5402185 commit d8bbfbf

File tree

10 files changed

+237
-214
lines changed

10 files changed

+237
-214
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ClassicReportBuilderTests
1212
[MethodImpl(MethodImplOptions.NoInlining)]
1313
public void ShouldProduceExpectedHtml()
1414
{
15-
Func<FileReportModel> model = () =>
15+
var model =
1616
new HtmlReportModel(new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMilliseconds()
1717
.ToReportModel())
1818
{
@@ -27,12 +27,11 @@ public void ShouldProduceExpectedHtml()
2727
[MethodImpl(MethodImplOptions.NoInlining)]
2828
public void ShouldProduceExpectedHtmlWithExamples()
2929
{
30-
Func<FileReportModel> model = () =>
31-
new HtmlReportModel(new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples()
32-
.ToReportModel())
33-
{
34-
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
35-
};
30+
var reportData = new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples().ToReportModel();
31+
var model = new HtmlReportModel(reportData)
32+
{
33+
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
34+
};
3635

3736
var sut = new ClassicReportBuilder();
3837
ReportApprover.Approve(model, sut);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class MetroReportBuilderTests
1212
[MethodImpl(MethodImplOptions.NoInlining)]
1313
public void ShouldProduceExpectedHtml()
1414
{
15-
Func<FileReportModel> model = () =>
15+
var model =
1616
new HtmlReportModel(new ReportTestData().CreateMixContainingEachTypeOfOutcome().ToReportModel())
1717
{
1818
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
@@ -26,7 +26,7 @@ public void ShouldProduceExpectedHtml()
2626
[MethodImpl(MethodImplOptions.NoInlining)]
2727
public void ShouldProduceExpectedHtmlWithExamples()
2828
{
29-
Func<FileReportModel> model = () =>
29+
var model =
3030
new HtmlReportModel(new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples()
3131
.ToReportModel())
3232
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class MarkDownReportBuilderTests
1212
[MethodImpl(MethodImplOptions.NoInlining)]
1313
public void ShouldProduceExpectedMarkdown()
1414
{
15-
Func<FileReportModel> model = () => new FileReportModel(new ReportTestData().CreateMixContainingEachTypeOfOutcome().ToReportModel());
15+
var model = new FileReportModel(new ReportTestData().CreateMixContainingEachTypeOfOutcome().ToReportModel());
1616
var sut = new MarkDownReportBuilder();
1717
ReportApprover.Approve(model, sut);
1818
}
@@ -21,7 +21,7 @@ public void ShouldProduceExpectedMarkdown()
2121
[MethodImpl(MethodImplOptions.NoInlining)]
2222
public void ShouldProduceExpectedMarkdownWithExamples()
2323
{
24-
Func<FileReportModel> model = () =>
24+
var model =
2525
new FileReportModel(new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples()
2626
.ToReportModel())
2727
{

TestStack.BDDfy.Tests/Reporters/ReportApprover.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ namespace TestStack.BDDfy.Tests.Reporters
99
{
1010
class ReportApprover
1111
{
12-
public static void Approve(Func<FileReportModel> model, IReportBuilder reportBuilder)
12+
public static void Approve(FileReportModel model, IReportBuilder reportBuilder)
1313
{
1414
// setting the culture to make sure the date is formatted the same on all machines
1515
using (new TemporaryCulture("en-GB"))
1616
{
17-
var result = reportBuilder.CreateReport(model());
17+
var result = reportBuilder.CreateReport(model);
1818
Approvals.Verify(result, s => Scrub(StackTraceScrubber.ScrubLineNumbers(StackTraceScrubber.ScrubPaths(s))));
1919
}
2020
}

TestStack.BDDfy.Tests/TagsTests.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@ public void TagsAreReportedInTextReport()
2929
[MethodImpl(MethodImplOptions.NoInlining)]
3030
public void TagsAreReportedInHtmlReport()
3131
{
32-
var story = this.Given(_ => GivenAStep())
33-
.WithTags("Tag1", "Tag 2")
34-
.BDDfy();
35-
Func<FileReportModel> model = () => new HtmlReportModel(new[] { story }.ToReportModel())
36-
{
37-
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
38-
};
32+
var model = new HtmlReportModel(this.CreateReportModel()) {
33+
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
34+
};
3935

4036
var sut = new ClassicReportBuilder();
4137
ReportApprover.Approve(model, sut);
@@ -45,13 +41,11 @@ public void TagsAreReportedInHtmlReport()
4541
[MethodImpl(MethodImplOptions.NoInlining)]
4642
public void TagsAreReportedInMetroHtmlReport()
4743
{
48-
var story = this.Given(_ => GivenAStep())
49-
.WithTags("Tag1", "Tag 2")
50-
.BDDfy();
51-
Func<FileReportModel> model = () => new HtmlReportModel(new[] { story }.ToReportModel())
52-
{
53-
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
54-
};
44+
var reportModel = this.CreateReportModel();
45+
var model = new HtmlReportModel(reportModel)
46+
{
47+
RunDate = new DateTime(2014, 3, 25, 11, 30, 5)
48+
};
5549

5650
var sut = new MetroReportBuilder();
5751
ReportApprover.Approve(model, sut);
@@ -61,10 +55,8 @@ public void TagsAreReportedInMetroHtmlReport()
6155
[MethodImpl(MethodImplOptions.NoInlining)]
6256
public void TagsAreReportedInMarkdownReport()
6357
{
64-
var story = this.Given(_ => GivenAStep())
65-
.WithTags("Tag1", "Tag 2")
66-
.BDDfy();
67-
Func<FileReportModel> model = () => new FileReportModel(new[] { story }.ToReportModel());
58+
var reportModel = this.CreateReportModel();
59+
var model = new FileReportModel(reportModel);
6860
var sut = new MarkDownReportBuilder();
6961
ReportApprover.Approve(model, sut);
7062
}
@@ -73,5 +65,14 @@ private void GivenAStep()
7365
{
7466

7567
}
68+
69+
private ReportModel CreateReportModel()
70+
{
71+
var story = this.Given(_ => GivenAStep())
72+
.WithTags("Tag1", "Tag 2")
73+
.BDDfy();
74+
var reportModel = new[] { story }.ToReportModel();
75+
return reportModel;
76+
}
7677
}
7778
}

TestStack.BDDfy/Reporters/Class1.cs

Lines changed: 0 additions & 180 deletions
This file was deleted.

TestStack.BDDfy/Reporters/FileReportModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ group story by story.Metadata.Type.Name into g
3535

3636
var aggregatedStories =
3737
from story in groupedByStories.Union(groupedByNamespace)
38-
select new ReportModel.Story() // order scenarios by title
38+
select new ReportModel.Story()
3939
{
40-
Namespace = story.Key
40+
Metadata = story.First().Metadata,
41+
Namespace = story.Key,
42+
Result = story.First().Result,
43+
Scenarios = story.SelectMany(s => s.Scenarios).OrderBy(s => s.Title).ToList() // order scenarios by title,
4144
};
4245

4346
return aggregatedStories;

0 commit comments

Comments
 (0)