File tree Expand file tree Collapse file tree 3 files changed +25
-31
lines changed
src/TestStack.BDDfy/Reporters Expand file tree Collapse file tree 3 files changed +25
-31
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public virtual string ReportDescription
20
20
set { _reportDescription = value ; }
21
21
}
22
22
23
- private string _outputPath = AssemblyDirectory ;
23
+ private string _outputPath = FileHelpers . AssemblyDirectory ( ) ;
24
24
public virtual string OutputPath
25
25
{
26
26
get { return _outputPath ; }
@@ -45,17 +45,5 @@ public virtual bool RunsOn(Story story)
45
45
{
46
46
return true ;
47
47
}
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
- }
60
48
}
61
49
}
Original file line number Diff line number Diff line change @@ -8,29 +8,12 @@ public class FileWriter : IReportWriter
8
8
{
9
9
public void OutputReport ( string reportData , string reportName , string outputDirectory = null )
10
10
{
11
- string directory = outputDirectory ?? GetDefaultOutputDirectory ;
11
+ string directory = outputDirectory ?? FileHelpers . AssemblyDirectory ( ) ;
12
12
var path = Path . Combine ( directory , reportName ) ;
13
13
14
14
if ( File . Exists ( path ) )
15
15
File . Delete ( path ) ;
16
16
File . WriteAllText ( path , reportData ) ;
17
17
}
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
- }
35
18
}
36
19
}
You can’t perform that action at this time.
0 commit comments