1
- using System . Collections . Generic ;
2
- using System . IO ;
3
- using Infralution . Localization . Wpf ;
1
+ using Infralution . Localization . Wpf ;
4
2
using NLog ;
5
3
using Rubberduck . Common ;
6
4
using Rubberduck . Interaction ;
7
5
using Rubberduck . Settings ;
8
6
using Rubberduck . UI . Command . MenuItems ;
9
7
using System ;
8
+ using System . Collections . Generic ;
10
9
using System . Diagnostics ;
11
10
using System . Globalization ;
12
11
using System . Linq ;
13
12
using Rubberduck . Parsing . UIContext ;
14
13
using Rubberduck . Resources ;
15
- using Rubberduck . Runtime ;
16
14
using Rubberduck . UI . Command ;
17
15
using Rubberduck . VBEditor . Utility ;
18
16
using Rubberduck . VersionCheck ;
19
17
using Application = System . Windows . Forms . Application ;
20
18
using Rubberduck . SettingsProvider ;
19
+ using System . IO . Abstractions ;
21
20
22
21
namespace Rubberduck
23
22
{
@@ -33,13 +32,15 @@ public sealed class App : IDisposable
33
32
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
34
33
35
34
private Configuration _config ;
35
+ private IFileSystem _filesystem ;
36
36
37
37
public App ( IMessageBox messageBox ,
38
38
IConfigurationService < Configuration > configService ,
39
39
IAppMenu appMenus ,
40
40
IRubberduckHooks hooks ,
41
41
IVersionCheck version ,
42
- CommandBase checkVersionCommand )
42
+ CommandBase checkVersionCommand ,
43
+ IFileSystem filesystem )
43
44
{
44
45
_messageBox = messageBox ;
45
46
_configService = configService ;
@@ -49,6 +50,7 @@ public App(IMessageBox messageBox,
49
50
_checkVersionCommand = checkVersionCommand ;
50
51
51
52
_configService . SettingsChanged += _configService_SettingsChanged ;
53
+ _filesystem = filesystem ;
52
54
53
55
UiContextProvider . Initialize ( ) ;
54
56
}
@@ -65,13 +67,13 @@ private void _configService_SettingsChanged(object sender, ConfigurationChangedE
65
67
}
66
68
}
67
69
68
- private static void EnsureLogFolderPathExists ( )
70
+ private void EnsureLogFolderPathExists ( )
69
71
{
70
72
try
71
73
{
72
- if ( ! Directory . Exists ( ApplicationConstants . LOG_FOLDER_PATH ) )
74
+ if ( ! _filesystem . Directory . Exists ( ApplicationConstants . LOG_FOLDER_PATH ) )
73
75
{
74
- Directory . CreateDirectory ( ApplicationConstants . LOG_FOLDER_PATH ) ;
76
+ _filesystem . Directory . CreateDirectory ( ApplicationConstants . LOG_FOLDER_PATH ) ;
75
77
}
76
78
}
77
79
catch
@@ -80,15 +82,15 @@ private static void EnsureLogFolderPathExists()
80
82
}
81
83
}
82
84
83
- private static void EnsureTempPathExists ( )
85
+ private void EnsureTempPathExists ( )
84
86
{
85
87
// This is required by the parser - allow this to throw.
86
- if ( ! Directory . Exists ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) )
88
+ if ( ! _filesystem . Directory . Exists ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) )
87
89
{
88
- Directory . CreateDirectory ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) ;
90
+ _filesystem . Directory . CreateDirectory ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) ;
89
91
}
90
92
// The parser swallows the error if deletions fail - clean up any temp files on startup
91
- foreach ( var file in new DirectoryInfo ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) . GetFiles ( ) )
93
+ foreach ( var file in _filesystem . DirectoryInfo . FromDirectoryName ( ApplicationConstants . RUBBERDUCK_TEMP_PATH ) . GetFiles ( ) )
92
94
{
93
95
try
94
96
{
@@ -241,7 +243,7 @@ public void LogRubberduckStart()
241
243
{
242
244
$ "\t Host Product: { Application . ProductName } { ( Environment . Is64BitProcess ? "x64" : "x86" ) } ",
243
245
$ "\t Host Version: { Application . ProductVersion } ",
244
- $ "\t Host Executable: { Path . GetFileName ( Application . ExecutablePath ) . ToUpper ( ) } ", // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE
246
+ $ "\t Host Executable: { _filesystem . Path . GetFileName ( Application . ExecutablePath ) . ToUpper ( ) } ", // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE
245
247
} ) ;
246
248
}
247
249
catch
0 commit comments