", exceptionId), HtmlTag.div))
{
diff --git a/src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs b/src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs
index 021217ef..8a4a9409 100644
--- a/src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs
+++ b/src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs
@@ -51,9 +51,9 @@ private static string AssemblyDirectory
{
get
{
- string codeBase = Assembly.GetExecutingAssembly().CodeBase;
+ var codeBase = typeof(DefaultHtmlReportConfiguration).Assembly().CodeBase;
var uri = new UriBuilder(codeBase);
- string path = Uri.UnescapeDataString(uri.Path);
+ var path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
diff --git a/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.Designer.cs b/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.Designer.cs
deleted file mode 100644
index 070729c8..00000000
--- a/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.Designer.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace TestStack.BDDfy.Reporters.Html {
- using System;
- using System.Reflection;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class HtmlReportResources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- internal HtmlReportResources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestStack.BDDfy.HtmlReportResources", typeof(HtmlReportResources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff;font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif}ul{margin:5px;padding:5px;border:1px solid #d0d0d0;-ms-border-radius:10px;border-radius:10px;background-color:#f0f0f0}li{list-style-type:none}#main{width:100%;height:100%}.header,.footer{background:#679bdb;background:-moz-linear-gradient(top,#679bdb 1%,#3b77a5 100%);background:-ms-linear-gradient(top,#679bdb 1%,#3b77a5 100%);background:-o-linear-gradient(top,#679bdb [rest of string was truncated]";.
- ///
- public static string classic_css_min {
- get {
- return ResourceManager.GetString("classic_css_min", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to $(function(){$(".canToggle").each(function(){var n=$("#"+$(this).data("toggle-target"));n.hide();$(this).click(function(){n.toggle(200)})});$(".expandAll").click(function(){$(".steps").css("display","")});$(".collapseAll").click(function(){$(".steps").css("display","none")});$("ul.resultSummary li:not('.storySummary'):not('.scenarioSummary')").append("<input type='checkbox' class='cbx_toggle' checked/>");$(".cbx_toggle").click(function(){var n=$(this),t=n.closest("li").attr("class");$("#testResult div.scena [rest of string was truncated]";.
- ///
- public static string classic_js_min {
- get {
- return ResourceManager.GetString("classic_js_min", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to If you drop a custom Javascript named BDDfyCustom.js in your output folder it gets embedded here. This way you can apply some custom Javascript logic to your html report..
- ///
- public static string CustomJavascriptComment {
- get {
- return ResourceManager.GetString("CustomJavascriptComment", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to 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..
- ///
- public static string CustomStylesheetComment {
- get {
- return ResourceManager.GetString("CustomStylesheetComment", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to /*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
- ///!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init( [rest of string was truncated]";.
- ///
- public static string jquery_2_1_0_min {
- get {
- return ResourceManager.GetString("jquery_2_1_0_min", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details [rest of string was truncated]";.
- ///
- public static string metro_css_min {
- get {
- return ResourceManager.GetString("metro_css_min", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to $(function(){$(".canToggle").each(function(){var n=$("#"+$(this).data("toggle-target"));n.hide();$(this).click(function(){n.toggle(200)})});$(".expandAll").click(function(){$(".steps").css("display","")});$(".collapseAll").click(function(){$(".steps").css("display","none")});$("#filterOptions a").click(function(){var n=$(this).children("div"),t,i;n.toggleClass("filterTileDisabled");t=!n.hasClass("filterTileDisabled");i=n.data("target-class");$("div."+i).closest(".scenario").toggle(t)})});
- ////*
- /////# sourceMap [rest of string was truncated]";.
- ///
- public static string metro_js_min {
- get {
- return ResourceManager.GetString("metro_js_min", resourceCulture);
- }
- }
- }
-}
diff --git a/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.cs b/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.cs
new file mode 100644
index 00000000..62efea43
--- /dev/null
+++ b/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.cs
@@ -0,0 +1,34 @@
+using System.IO;
+
+namespace TestStack.BDDfy.Reporters.Html
+{
+ internal class HtmlReportResources
+ {
+ public static string metro_js_min => Read("TestStack.BDDfy.Reporters.Html.Scripts.metro.min.js");
+ public static string metro_css_min => Read("TestStack.BDDfy.Reporters.Html.Scripts.metro.min.css");
+ public static string classic_js_min => Read("TestStack.BDDfy.Reporters.Html.Scripts.classic.min.js");
+ public static string jquery_2_1_0_min => Read("TestStack.BDDfy.Reporters.Html.Scripts.jquery-2.1.0.min.js");
+ public static string classic_css_min => Read("TestStack.BDDfy.Reporters.Html.Scripts.classic.min.css");
+
+ public static string CustomStylesheetComment =>
+ "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.";
+
+ public static string CustomJavascriptComment =>
+ "If you drop a custom Javascript named BDDfyCustom.js in your output folder" +
+ " it gets embedded here. This way you can apply some custom Javascript logic" +
+ " to your html report.";
+
+ static string Read(string resourceName)
+ {
+ var assembly = typeof(HtmlReportResources).Assembly();
+
+ using (var stream = assembly.GetManifestResourceStream(resourceName))
+ using (var reader = new StreamReader(stream))
+ {
+ return reader.ReadToEnd();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.resx b/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.resx
deleted file mode 100644
index dbc2e931..00000000
--- a/src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.resx
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- Scripts\classic.min.css;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
- Scripts\classic.min.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
- If you drop a custom Javascript named BDDfyCustom.js in your output folder it gets embedded here. This way you can apply some custom Javascript logic to your html report.
-
-
- 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.
-
-
- Scripts\jquery-2.1.0.min.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
- Scripts\metro.min.css;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
- Scripts\metro.min.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
-
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/Reporters/Html/MetroReportBuilder.cs b/src/TestStack.BDDfy/Reporters/Html/MetroReportBuilder.cs
index ecf5b3ef..b29e0bc7 100644
--- a/src/TestStack.BDDfy/Reporters/Html/MetroReportBuilder.cs
+++ b/src/TestStack.BDDfy/Reporters/Html/MetroReportBuilder.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Text;
-using System.Web;
using TestStack.BDDfy.Configuration;
namespace TestStack.BDDfy.Reporters.Html
@@ -45,7 +45,7 @@ private void HtmlHead()
EmbedCssFile(HtmlReportResources.metro_css_min);
EmbedCssFile(_model.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
AddLine("
");
- AddLine(string.Format("
BDDfy Test Result {0}", _model.RunDate.ToShortDateString()));
+ AddLine(string.Format("
BDDfy Test Result {0}", _model.RunDate.AsShortDateTimeString()));
}
}
@@ -202,7 +202,7 @@ private void AddScenarioWithExamples(ReportModel.Scenario[] scenarioGroup)
var firstScenario = scenarioGroup.First();
var scenarioResult = (Result)scenarioGroup.Max(s => (int)s.Result);
- AddLine(string.Format("
{2}{3}
", scenarioResult, firstScenario.Id, HttpUtility.HtmlEncode(firstScenario.Title), FormatTags(firstScenario.Tags)));
+ AddLine(string.Format("
{2}{3}
", scenarioResult, firstScenario.Id, WebUtility.HtmlEncode(firstScenario.Title), FormatTags(firstScenario.Tags)));
using (OpenTag(string.Format("
", firstScenario.Id), HtmlTag.ul))
{
@@ -210,7 +210,7 @@ private void AddScenarioWithExamples(ReportModel.Scenario[] scenarioGroup)
{
using (OpenTag(string.Format("- ", step.ExecutionOrder), HtmlTag.li))
{
- var titleLines = HttpUtility.HtmlEncode(step.Title)
+ var titleLines = WebUtility.HtmlEncode(step.Title)
.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
var title = titleLines[0];
@@ -262,7 +262,7 @@ private void AddExampleRow(ReportModel.Scenario scenario, Result scenarioResult)
{
AddLine(string.Format("
| ", scenario.Result));
foreach (var exampleValue in scenario.Example.Values)
- AddLine(string.Format("{0} | ", HttpUtility.HtmlEncode(exampleValue.GetValueAsString())));
+ AddLine(string.Format("{0} | ", WebUtility.HtmlEncode(exampleValue.GetValueAsString())));
if (scenarioResult != Result.Failed)
return;
@@ -275,7 +275,7 @@ private void AddExampleRow(ReportModel.Scenario scenario, Result scenarioResult)
return;
var exceptionId = Configurator.IdGenerator.GetStepId();
- var encodedExceptionMessage = HttpUtility.HtmlEncode(failingStep.Exception.Message);
+ var encodedExceptionMessage = WebUtility.HtmlEncode(failingStep.Exception.Message);
AddLine(string.Format("{1}", exceptionId, encodedExceptionMessage));
using (OpenTag(string.Format("", exceptionId), HtmlTag.div))
{
@@ -287,7 +287,7 @@ private void AddExampleRow(ReportModel.Scenario scenario, Result scenarioResult)
private void AddScenario(ReportModel.Scenario scenario)
{
- AddLine(string.Format("
{2}{3}
", scenario.Result, scenario.Id, HttpUtility.HtmlEncode(scenario.Title), FormatTags(scenario.Tags)));
+ AddLine(string.Format("
{2}{3}
", scenario.Result, scenario.Id, WebUtility.HtmlEncode(scenario.Title), FormatTags(scenario.Tags)));
using (OpenTag(string.Format("
", scenario.Id), HtmlTag.ul))
{
diff --git a/src/TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs b/src/TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs
index 8efa5e2f..4d1105bc 100644
--- a/src/TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs
+++ b/src/TestStack.BDDfy/Reporters/MarkDown/MarkDownReportBuilder.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Text;
-using System.Web;
namespace TestStack.BDDfy.Reporters.MarkDown
{
@@ -41,7 +41,7 @@ public string CreateReport(FileReportModel model)
if (exampleScenario.Steps.Any())
{
foreach (var step in exampleScenario.Steps.Where(s => s.ShouldReport))
- report.AppendLine(" " + HttpUtility.HtmlEncode(step.Title) + " ");
+ report.AppendLine(" " + WebUtility.HtmlEncode(step.Title) + " ");
}
report.AppendLine(); // separator
@@ -55,7 +55,7 @@ public string CreateReport(FileReportModel model)
report.AppendLine(string.Format("### {0}", scenario.Title));
foreach (var step in scenario.Steps.Where(s => s.ShouldReport))
- report.AppendLine(" " + HttpUtility.HtmlEncode(step.Title) + " ");
+ report.AppendLine(" " + WebUtility.HtmlEncode(step.Title) + " ");
report.AppendLine(); // separator
}
@@ -121,7 +121,7 @@ private void WriteExamples(StringBuilder report, ReportModel.Scenario exampleSce
var failingStep = scenario.Steps.FirstOrDefault(s => s.Result == Result.Failed);
var error = failingStep == null
? null
- : string.Format("Step: {0} failed with exception: {1}", HttpUtility.HtmlEncode(failingStep.Title), CreateExceptionMessage(failingStep));
+ : string.Format("Step: {0} failed with exception: {1}", WebUtility.HtmlEncode(failingStep.Title), CreateExceptionMessage(failingStep));
addRow(scenario.Example.Values.Select(e => e.GetValueAsString()), scenario.Result.ToString(), error);
}
diff --git a/src/TestStack.BDDfy/Reporters/Serializers/JsonSerializer.cs b/src/TestStack.BDDfy/Reporters/Serializers/JsonSerializer.cs
index 7e250b57..a2b81166 100644
--- a/src/TestStack.BDDfy/Reporters/Serializers/JsonSerializer.cs
+++ b/src/TestStack.BDDfy/Reporters/Serializers/JsonSerializer.cs
@@ -1,7 +1,8 @@
-using System.Web.Script.Serialization;
-
namespace TestStack.BDDfy.Reporters.Serializers
{
+#if NET40
+ using System.Web.Script.Serialization;
+
public class JsonSerializer : ISerializer
{
public string Serialize(object obj)
@@ -12,4 +13,23 @@ public string Serialize(object obj)
return new JsonFormatter(json).Format();
}
}
+
+#else
+ using Newtonsoft.Json;
+
+ public class JsonSerializer : ISerializer
+ {
+ public string Serialize(object obj)
+ {
+ return JsonConvert.SerializeObject(obj, Formatting.Indented,
+ new JsonSerializerSettings
+ {
+ NullValueHandling = NullValueHandling.Ignore,
+ ReferenceLoopHandling = ReferenceLoopHandling.Ignore
+ });
+ }
+ }
+
+#endif
+
}
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs b/src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs
index ef12a3ec..1767eed6 100644
--- a/src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs
+++ b/src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs
@@ -20,7 +20,7 @@ private static string GetDefaultOutputDirectory
{
get
{
- string codeBase = typeof(DiagnosticsReporter).Assembly.CodeBase;
+ string codeBase = typeof(DiagnosticsReporter).Assembly().CodeBase;
var uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
diff --git a/src/TestStack.BDDfy/Scanners/ScenarioScanners/FluentScenarioScanner.cs b/src/TestStack.BDDfy/Scanners/ScenarioScanners/FluentScenarioScanner.cs
index 5eda6a0b..87273685 100644
--- a/src/TestStack.BDDfy/Scanners/ScenarioScanners/FluentScenarioScanner.cs
+++ b/src/TestStack.BDDfy/Scanners/ScenarioScanners/FluentScenarioScanner.cs
@@ -1,6 +1,7 @@
-using System.Collections.Generic;
-using System.Linq;
+using System;
+using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using TestStack.BDDfy.Configuration;
namespace TestStack.BDDfy
@@ -36,12 +37,23 @@ private List CloneSteps(IEnumerable steps)
private static string GetTitleFromMethodNameInStackTrace(object testObject)
{
- var trace = new StackTrace();
+ // ReSharper disable once JoinDeclarationAndInitializer
+ StackTrace trace;
+#if STACKTRACE
+ trace = new StackTrace();
+#else
+ try
+ {
+ throw new Exception();
+ }
+ catch (Exception e)
+ {
+ trace = new StackTrace(e, false);
+ }
+#endif
var frames = trace.GetFrames();
- if (frames == null)
- return null;
- var initiatingFrame = frames.LastOrDefault(s => s.GetMethod().DeclaringType == testObject.GetType());
+ var initiatingFrame = frames?.LastOrDefault(s => s.GetMethod().DeclaringType == testObject.GetType());
if (initiatingFrame == null)
return null;
diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs
index 21f37eb5..52820db4 100644
--- a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs
+++ b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs
@@ -91,7 +91,7 @@ public static bool HeaderMatches(string header, string name)
if (name == null)
return false;
- return Sanitise(name).Equals(Sanitise(header), StringComparison.InvariantCultureIgnoreCase);
+ return Sanitise(name).ToLower().Equals(Sanitise(header).ToLower());
}
private static string Sanitise(string value)
diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleValue.cs b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleValue.cs
index 8b909c84..a0d581c0 100644
--- a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleValue.cs
+++ b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleValue.cs
@@ -34,7 +34,7 @@ public object GetValue(Type targetType)
var stringValue = _underlyingValue as string;
if (_underlyingValue == null)
{
- if (targetType.IsValueType && !(targetType.IsGenericType && targetType.GetGenericTypeDefinition() == typeof(Nullable<>)))
+ if (targetType.IsValueType() && !(targetType.IsGenericType() && targetType.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
var valueAsString = string.IsNullOrEmpty(stringValue) ? "" : string.Format("\"{0}\"", _underlyingValue);
throw new ArgumentException(string.Format("Cannot convert {0} to {1} (Column: '{2}', Row: {3})", valueAsString, targetType.Name, Header, Row));
@@ -48,7 +48,7 @@ public object GetValue(Type targetType)
if (targetType.IsInstanceOfType(_underlyingValue))
return _underlyingValue;
- if (targetType.IsEnum && _underlyingValue is string)
+ if (targetType.IsEnum() && _underlyingValue is string)
return Enum.Parse(targetType, (string)_underlyingValue);
if (targetType == typeof(DateTime))
diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/UnassignableExampleException.cs b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/UnassignableExampleException.cs
index f374c272..e056e7fc 100644
--- a/src/TestStack.BDDfy/Scanners/StepScanners/Examples/UnassignableExampleException.cs
+++ b/src/TestStack.BDDfy/Scanners/StepScanners/Examples/UnassignableExampleException.cs
@@ -10,6 +10,7 @@ public UnassignableExampleException(string message, Exception inner, ExampleValu
{
ExampleValue = exampleValue;
}
+#if NET40
protected UnassignableExampleException(
SerializationInfo info,
@@ -17,6 +18,7 @@ protected UnassignableExampleException(
{
}
+#endif
public ExampleValue ExampleValue { get; private set; }
}
}
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs b/src/TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs
index 33efc439..92e5f393 100644
--- a/src/TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs
+++ b/src/TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs
@@ -64,7 +64,7 @@ public void AddStep(Action stepAction, string title, bool reports, ExecutionOrde
private string AppendPrefix(string title, string stepPrefix)
{
- if (!title.StartsWith(stepPrefix, StringComparison.InvariantCultureIgnoreCase))
+ if (!title.ToLower().StartsWith(stepPrefix.ToLower()))
{
if (title.Length == 0)
return string.Format("{0} ", stepPrefix);
diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/StepTitleException.cs b/src/TestStack.BDDfy/Scanners/StepScanners/StepTitleException.cs
index 09c4dc1c..1e68d310 100644
--- a/src/TestStack.BDDfy/Scanners/StepScanners/StepTitleException.cs
+++ b/src/TestStack.BDDfy/Scanners/StepScanners/StepTitleException.cs
@@ -16,10 +16,12 @@ public StepTitleException(string message) : base(message)
public StepTitleException(string message, Exception innerException) : base(message, innerException)
{
}
+ #if NET40
- protected StepTitleException(SerializationInfo info, StreamingContext context)
+ protected StepTitleException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
+#endif
}
}
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/Scanners/StoryAttributeMetaDataScanner.cs b/src/TestStack.BDDfy/Scanners/StoryAttributeMetaDataScanner.cs
index d89ea4fb..d7b23c68 100644
--- a/src/TestStack.BDDfy/Scanners/StoryAttributeMetaDataScanner.cs
+++ b/src/TestStack.BDDfy/Scanners/StoryAttributeMetaDataScanner.cs
@@ -39,14 +39,26 @@ protected virtual Type GetCandidateStory(object testObject, Type explicitStoryTy
if (explicitStoryType != null)
return explicitStoryType;
- var stackTrace = new StackTrace();
+ // ReSharper disable once JoinDeclarationAndInitializer
+ StackTrace stackTrace;
+#if STACKTRACE
+ stackTrace = new StackTrace();
+#else
+ try
+ {
+ throw new Exception();
+ }
+ catch (Exception e)
+ {
+ stackTrace = new StackTrace(e, false);
+ }
+#endif
var frames = stackTrace.GetFrames();
if (frames == null)
return null;
-
var scenarioType = testObject.GetType();
// This is assuming scenario and story live in the same assembly
- var firstFrame = frames.LastOrDefault(f => f.GetMethod().DeclaringType.Assembly == scenarioType.Assembly);
+ var firstFrame = frames.LastOrDefault(f => f.GetMethod().DeclaringType.Assembly() == scenarioType.Assembly());
if (firstFrame == null)
return null;
diff --git a/src/TestStack.BDDfy/SerializableAttribute.cs b/src/TestStack.BDDfy/SerializableAttribute.cs
new file mode 100644
index 00000000..85100866
--- /dev/null
+++ b/src/TestStack.BDDfy/SerializableAttribute.cs
@@ -0,0 +1,10 @@
+#if NET40
+
+#else
+namespace System.Runtime.Serialization
+{
+ public class SerializableAttribute : Attribute
+ {
+ }
+}
+#endif
\ No newline at end of file
diff --git a/src/TestStack.BDDfy/TypeExtensions.cs b/src/TestStack.BDDfy/TypeExtensions.cs
new file mode 100644
index 00000000..d20d7329
--- /dev/null
+++ b/src/TestStack.BDDfy/TypeExtensions.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Reflection;
+
+namespace TestStack.BDDfy
+{
+#if NET40
+ public static class TypeExtensions
+ {
+ public static Assembly Assembly(this Type type)
+ {
+ return type.Assembly;
+ }
+
+ public static object[] GetCustomAttributes(this Type type, Type attributeType, bool inherit)
+ {
+ return type.GetCustomAttributes(attributeType, inherit);
+ }
+
+ public static bool IsEnum(this Type type)
+ {
+ return type.IsEnum;
+ }
+
+ public static bool IsGenericType(this Type type)
+ {
+ return type.IsGenericType;
+ }
+
+ public static bool IsInstanceOfType(this Type type, object obj)
+ {
+ return type.IsInstanceOfType(obj);
+ }
+
+ public static bool IsValueType(this Type type)
+ {
+ return type.IsValueType;
+ }
+ }
+
+#else
+using System.Linq;
+ public static class TypeExtensions
+ {
+ public static Assembly Assembly(this Type type)
+ {
+ return type.GetTypeInfo().Assembly;
+
+ }
+
+ public static object[] GetCustomAttributes(this Type type, Type attributeType, bool inherit)
+ {
+ return type.GetTypeInfo()
+ .GetCustomAttributes(attributeType, inherit)
+ .Cast