Skip to content

Commit d0746af

Browse files
committed
Merge pull request #71 from MehdiK/jquery-config-point
config point for resolving jquery thru CDN or embedding it
2 parents bce4d0d + 2effea4 commit d0746af

10 files changed

Lines changed: 55 additions & 11 deletions

Samples/TestStack.BDDfy.Samples/Atm/HtmlReportConfig.cs renamed to Samples/TestStack.BDDfy.Samples/Atm/AtmHtmlReportConfig.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using TestStack.BDDfy.Processors;
1+
using System;
22
using TestStack.BDDfy.Reporters.Html;
33

44
namespace TestStack.BDDfy.Samples.Atm
55
{
66
/// <summary>
77
/// This overrides the default html report setting
88
/// </summary>
9-
public class HtmlReportConfig : DefaultHtmlReportConfiguration
9+
public class AtmHtmlReportConfig : DefaultHtmlReportConfiguration
1010
{
1111
public override bool RunsOn(Story story)
1212
{
13-
return story.Metadata.Type.Namespace != null && story.Metadata.Type.Namespace.EndsWith("Atm");
13+
return story.Namespace.EndsWith("Atm", StringComparison.OrdinalIgnoreCase);
1414
}
1515

1616
/// <summary>
@@ -45,5 +45,13 @@ public override string ReportDescription
4545
return "A reliable solution for your offline banking needs";
4646
}
4747
}
48+
49+
/// <summary>
50+
/// For ATM report I want to embed jQuery in the report so people can see it with no internet connectivity
51+
/// </summary>
52+
public override bool ResolveJqueryFromCdn
53+
{
54+
get { return false; }
55+
}
4856
}
4957
}

Samples/TestStack.BDDfy.Samples/BDDfyConfiguration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using NUnit.Framework;
22
using TestStack.BDDfy.Configuration;
3-
using TestStack.BDDfy.Processors;
43
using TestStack.BDDfy.Reporters.Html;
54
using TestStack.BDDfy.Samples.Atm;
65

@@ -15,7 +14,7 @@ public void Config()
1514
Configurator.Processors.Add(() => new CustomTextReporter());
1615
Configurator.BatchProcessors.MarkDownReport.Enable();
1716
Configurator.BatchProcessors.DiagnosticsReport.Enable();
18-
Configurator.BatchProcessors.Add(new HtmlReporter(new HtmlReportConfig()));
17+
Configurator.BatchProcessors.Add(new HtmlReporter(new AtmHtmlReportConfig()));
1918
}
2019
}
2120
}

Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<Compile Include="Atm\AccountHasInsufficientFund.cs" />
4949
<Compile Include="Atm\Atm.cs" />
5050
<Compile Include="Atm\AccountHolderWithdrawsCash.cs" />
51-
<Compile Include="Atm\HtmlReportConfig.cs" />
51+
<Compile Include="Atm\AtmHtmlReportConfig.cs" />
5252
<Compile Include="BDDfyConfiguration.cs" />
5353
<Compile Include="BDDfy_Rocks.cs" />
5454
<Compile Include="CanWorkWithoutAStory.cs" />

TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,39 @@ namespace TestStack.BDDfy.Reporters.Html
66
{
77
public class DefaultHtmlReportConfiguration : IHtmlReportConfiguration
88
{
9+
private string _reportHeader = "BDDfy";
910
public virtual string ReportHeader
1011
{
11-
get { return "BDDfy"; }
12+
get { return _reportHeader; }
13+
set { _reportHeader = value; }
1214
}
1315

16+
private string _reportDescription = "A simple BDD framework for .Net developers";
1417
public virtual string ReportDescription
1518
{
16-
get { return "A simple BDD framework for .Net developers"; }
19+
get { return _reportDescription; }
20+
set { _reportDescription = value; }
1721
}
1822

23+
private string _outputPath = AssemblyDirectory;
1924
public virtual string OutputPath
2025
{
21-
get { return AssemblyDirectory; }
26+
get { return _outputPath; }
27+
set { _outputPath = value; }
2228
}
2329

2430
private string _outputFileName = "BDDfy.html";
2531
public virtual string OutputFileName
2632
{
2733
get { return _outputFileName; }
34+
set { _outputFileName = value; }
35+
}
36+
37+
private bool _resolveJqueryFromCdn = true;
38+
public virtual bool ResolveJqueryFromCdn
39+
{
40+
get { return _resolveJqueryFromCdn; }
41+
set { _resolveJqueryFromCdn = value; }
2842
}
2943

3044
public virtual bool RunsOn(Story story)

TestStack.BDDfy/Reporters/Html/HtmlReportBuilder.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ private void ResultDetails()
135135
private void Footer()
136136
{
137137
AddLine("<div class='footer'>Powered by <a href='https://github.com/TestStack/TestStack.BDDfy'>BDDfy</a> framework</div>");
138-
139-
AddLine("<script type='text/javascript' src='https://code.jquery.com/jquery-1.11.0.min.js'></script>");
138+
139+
if (_viewModel.Configuration.ResolveJqueryFromCdn)
140+
AddLine("<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.0.min.js'></script>");
141+
else
142+
EmbedJavascriptFile(HtmlReportResources.jquery_2_1_0_min);
143+
140144
EmbedJavascriptFile(HtmlReportResources.BDDfy_js);
141145
EmbedJavascriptFile(_viewModel.CustomJavascript, HtmlReportResources.CustomJavascriptComment);
142146
}

TestStack.BDDfy/Reporters/Html/HtmlReportResources.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestStack.BDDfy/Reporters/Html/HtmlReportResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,7 @@
130130
<data name="CustomStylesheetComment" xml:space="preserve">
131131
<value>If you drop a custom stylesheet named BDDfyCustom.css in your output folder it gets embedded here. This way you can apply some custom styles over your html report.</value>
132132
</data>
133+
<data name="jquery_2_1_0_min" type="System.Resources.ResXFileRef, System.Windows.Forms">
134+
<value>jquery-2.1.0.min.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
135+
</data>
133136
</root>

TestStack.BDDfy/Reporters/Html/IHtmlReportConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface IHtmlReportConfiguration
66
string ReportDescription { get; }
77
string OutputPath { get; }
88
string OutputFileName { get; }
9+
bool ResolveJqueryFromCdn { get; }
910
bool RunsOn(Story story);
1011
}
1112
}

TestStack.BDDfy/Reporters/Html/jquery-2.1.0.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestStack.BDDfy/TestStack.BDDfy.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<ItemGroup>
161161
<Content Include="Reporters\Html\BDDfy.css" />
162162
<Content Include="Reporters\Html\BDDfy.js" />
163+
<Content Include="Reporters\Html\jquery-2.1.0.min.js" />
163164
</ItemGroup>
164165
<ItemGroup>
165166
<EmbeddedResource Include="Reporters\Html\HtmlReportResources.resx">

0 commit comments

Comments
 (0)