Skip to content

Commit 2d74ac0

Browse files
committed
Fixes BDDfy.html. Fixes #237
1 parent 96b4204 commit 2d74ac0

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace TestStack.BDDfy.Reporters
5+
{
6+
public class FileHelpers
7+
{
8+
// http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917
9+
internal static string AssemblyDirectory()
10+
{
11+
#if NET40
12+
string codeBase = typeof(Engine).Assembly().CodeBase;
13+
var uri = new UriBuilder(codeBase);
14+
string path = Uri.UnescapeDataString(uri.Path);
15+
return Path.GetDirectoryName(path);
16+
#else
17+
var basePath = AppContext.BaseDirectory;
18+
return Path.GetFullPath(basePath);
19+
#endif
20+
}
21+
22+
}
23+
}

src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public virtual string ReportDescription
2020
set { _reportDescription = value; }
2121
}
2222

23-
private string _outputPath = AssemblyDirectory;
23+
private string _outputPath = FileHelpers.AssemblyDirectory();
2424
public virtual string OutputPath
2525
{
2626
get { return _outputPath; }
@@ -45,17 +45,5 @@ public virtual bool RunsOn(Story story)
4545
{
4646
return true;
4747
}
48-
49-
// http://stackoverflow.com/questions/52797/c-how-do-i-get-the-path-of-the-assembly-the-code-is-in#answer-283917
50-
private static string AssemblyDirectory
51-
{
52-
get
53-
{
54-
var codeBase = typeof(DefaultHtmlReportConfiguration).Assembly().CodeBase;
55-
var uri = new UriBuilder(codeBase);
56-
var path = Uri.UnescapeDataString(uri.Path);
57-
return Path.GetDirectoryName(path);
58-
}
59-
}
6048
}
6149
}

src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,12 @@ public class FileWriter : IReportWriter
88
{
99
public void OutputReport(string reportData, string reportName, string outputDirectory = null)
1010
{
11-
string directory = outputDirectory ?? GetDefaultOutputDirectory;
11+
string directory = outputDirectory ?? FileHelpers.AssemblyDirectory();
1212
var path = Path.Combine(directory, reportName);
1313

1414
if (File.Exists(path))
1515
File.Delete(path);
1616
File.WriteAllText(path, reportData);
1717
}
18-
19-
private static string GetDefaultOutputDirectory
20-
{
21-
get
22-
{
23-
24-
#if NET40
25-
string codeBase = typeof(DiagnosticsReporter).Assembly().CodeBase;
26-
var uri = new UriBuilder(codeBase);
27-
string path = Uri.UnescapeDataString(uri.Path);
28-
return Path.GetDirectoryName(path);
29-
#else
30-
var basePath = AppContext.BaseDirectory;
31-
return Path.GetFullPath(basePath);
32-
#endif
33-
}
34-
}
3518
}
3619
}

0 commit comments

Comments
 (0)