Skip to content

Commit 6fb64e3

Browse files
committed
Merge pull request #98 from MehdiK/metro-report
Metro report
2 parents 514fb51 + 219aff0 commit 6fb64e3

22 files changed

Lines changed: 2563 additions & 36 deletions

Samples/TestStack.BDDfy.Samples/BDDfyConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using NUnit.Framework;
22
using TestStack.BDDfy.Configuration;
33
using TestStack.BDDfy.Reporters.Html;
4+
using TestStack.BDDfy.Reporters.HtmlMetro;
45
using TestStack.BDDfy.Samples.Atm;
56

67
namespace TestStack.BDDfy.Samples
@@ -14,7 +15,7 @@ public void Config()
1415
Configurator.Processors.Add(() => new CustomTextReporter());
1516
Configurator.BatchProcessors.MarkDownReport.Enable();
1617
Configurator.BatchProcessors.DiagnosticsReport.Enable();
17-
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig()));
18+
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig(), new HtmlMetroReportBuilder()));
1819
}
1920
}
2021
}

TestStack.BDDfy.Tests/Configuration/BatchProcessorsTests.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
using NUnit.Framework;
22
using System.Linq;
33
using TestStack.BDDfy.Configuration;
4-
using TestStack.BDDfy.Processors;
54
using TestStack.BDDfy.Reporters.Html;
5+
using TestStack.BDDfy.Reporters.HtmlMetro;
66
using TestStack.BDDfy.Reporters.MarkDown;
77

88
namespace TestStack.BDDfy.Tests.Configuration
99
{
1010
[TestFixture]
1111
public class BatchProcessorsTests
1212
{
13+
static bool MetroReportProcessorIsActive(IBatchProcessor batchProcessor)
14+
{
15+
return batchProcessor is HtmlReporter && ((HtmlReporter)batchProcessor).ReportBuilder is HtmlMetroReportBuilder;
16+
}
17+
1318
[Test]
1419
public void ReturnsHtmlReporterByDefault()
1520
{
@@ -24,24 +29,44 @@ public void DoesNotReturnMarkDownReporterByDefault()
2429
Assert.IsFalse(processors.Any(p => p is MarkDownReporter));
2530
}
2631

32+
[Test]
33+
public void DoesNotReturnHtmlMetroReporterByDefault()
34+
{
35+
var processors = Configurator.BatchProcessors.GetProcessors().ToList();
36+
Assert.IsFalse(processors.Any(MetroReportProcessorIsActive));
37+
}
38+
2739
[Test]
2840
public void DoesNotReturnHtmlReporterWhenItIsDeactivated()
2941
{
3042
Configurator.BatchProcessors.HtmlReport.Disable();
43+
3144
var processors = Configurator.BatchProcessors.GetProcessors().ToList();
32-
3345
Assert.IsFalse(processors.Any(p => p is HtmlReporter));
46+
3447
Configurator.BatchProcessors.HtmlReport.Enable();
3548
}
3649

3750
[Test]
3851
public void ReturnsMarkdownReporterWhenItIsActivated()
3952
{
4053
Configurator.BatchProcessors.MarkDownReport.Enable();
54+
4155
var processors = Configurator.BatchProcessors.GetProcessors().ToList();
42-
4356
Assert.IsTrue(processors.Any(p => p is MarkDownReporter));
57+
4458
Configurator.BatchProcessors.MarkDownReport.Disable();
4559
}
60+
61+
[Test]
62+
public void ReturnsHtmlMetroReporterWhenItIsActivated()
63+
{
64+
Configurator.BatchProcessors.HtmlMetroReport.Enable();
65+
66+
var processors = Configurator.BatchProcessors.GetProcessors().ToList();
67+
Assert.IsTrue(processors.Any(MetroReportProcessorIsActive), "The metro Html report was not found in batch processors");
68+
69+
Configurator.BatchProcessors.HtmlMetroReport.Disable();
70+
}
4671
}
4772
}

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
2-
using System.Globalization;
32
using System.IO;
43
using System.Reflection;
54
using System.Runtime.CompilerServices;
65
using System.Text.RegularExpressions;
7-
using System.Threading;
86
using ApprovalTests;
97
using ApprovalTests.Reporters;
108
using NUnit.Framework;
@@ -38,19 +36,4 @@ public void ShouldProduceExpectedHtml()
3836
}
3937
}
4038
}
41-
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);
54-
}
55-
}
5639
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void SetUp()
2525
[Test]
2626
public void ShouldCreateReportIfProcessingSucceeds()
2727
{
28-
_sut.Builder.CreateReport(Arg.Any<FileReportModel>()).Returns(ReportData);
28+
_sut.ReportBuilder.CreateReport(Arg.Any<FileReportModel>()).Returns(ReportData);
2929

3030
_sut.Process(new List<Story>());
3131

@@ -35,7 +35,7 @@ public void ShouldCreateReportIfProcessingSucceeds()
3535
[Test]
3636
public void ShouldPrintErrorInReportIfProcessingFails()
3737
{
38-
_sut.Builder.CreateReport(Arg.Any<FileReportModel>()).Returns(x => { throw new Exception(ErrorMessage); });
38+
_sut.ReportBuilder.CreateReport(Arg.Any<FileReportModel>()).Returns(x => { throw new Exception(ErrorMessage); });
3939

4040
_sut.Process(new ReportTestData().CreateTwoStoriesEachWithTwoScenariosWithThreeStepsOfFiveMilliseconds());
4141

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Threading;
4+
5+
namespace TestStack.BDDfy.Tests.Reporters.Html
6+
{
7+
public class TemporaryCulture : IDisposable
8+
{
9+
private readonly string _originalCulture;
10+
public TemporaryCulture(string newCulture)
11+
{
12+
_originalCulture = Thread.CurrentThread.CurrentCulture.Name;
13+
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(newCulture);
14+
}
15+
16+
public void Dispose()
17+
{
18+
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(_originalCulture);
19+
}
20+
}
21+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ namespace TestStack.BDDfy.Tests.Reporters.Html
99
public class TestableHtmlReporter : HtmlReporter
1010
{
1111
public IHtmlReportConfiguration Configuration { get; set; }
12-
public IReportBuilder Builder { get; set; }
1312
public IReportWriter Writer { get; set; }
1413
public IFileReader FileReader { get; set; }
1514

16-
public TestableHtmlReporter(IHtmlReportConfiguration configuration, IReportBuilder builder, IReportWriter writer, IFileReader fileReader)
17-
: base(configuration, builder, writer, fileReader)
15+
public TestableHtmlReporter(IHtmlReportConfiguration configuration, IReportBuilder reportBuilder, IReportWriter writer, IFileReader fileReader)
16+
: base(configuration, reportBuilder, writer, fileReader)
1817
{
1918
Configuration = configuration;
20-
Builder = builder;
19+
ReportBuilder = reportBuilder;
2120
Writer = writer;
2221
FileReader = fileReader;
2322
Configuration.RunsOn(Arg.Any<Story>()).Returns(true);

0 commit comments

Comments
 (0)