File tree Expand file tree Collapse file tree 4 files changed +42
-12
lines changed Expand file tree Collapse file tree 4 files changed +42
-12
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ To use this helper - register `IFileIO` is your `DI` with `FileIO` as the implme
43
43
- ReadAllText (path)
44
44
- FileExists(path)
45
45
- WriteAllLines(path, lines)
46
- - DeleteFile(path)
46
+ - DeleteFile(path)
47
+ - CreateDirectory (path)
48
+ - DeleteDirectory (path)
47
49
48
50
# Extension Methods
49
51
@@ -82,5 +84,6 @@ Merges to `main` publish to nuget as a major release.
82
84
# Change Log
83
85
- 1.1.0 - added IList.AddRange extension method
84
86
- 1.2.0 - never published - only preview
85
- - 1.3.0 - added IFileIO - an interface + implementation for making common filesystem opperations easier to test
86
- - 1.3.1 - suppressed some test warnings and updated the GH workflows
87
+ - 1.3.0 - added ` IFileIO ` - an interface + implementation for making common filesystem opperations easier to test
88
+ - 1.3.1 - suppressed some test warnings and updated the GH workflows
89
+ - 1.4.0 - added ` CreatedDiretory ` and ` DeleteDirectory ` to ` IFileIO `
Original file line number Diff line number Diff line change @@ -68,10 +68,6 @@ public void FilesExists_DoesNotExist()
68
68
result . Should ( ) . BeFalse ( ) ;
69
69
}
70
70
71
-
72
- //Need WriteAllLines
73
- //Need DeleteFile
74
-
75
71
[ Fact ]
76
72
public void WriteAllLines_withDeleteFile ( )
77
73
{
@@ -114,4 +110,33 @@ public void WriteAllLines_withDeleteFile()
114
110
var confirmDelete = _files . FileExists ( target ) ;
115
111
confirmDelete . Should ( ) . BeFalse ( ) ;
116
112
}
113
+
114
+ [ Fact ]
115
+ public void DirectoryTests ( )
116
+ {
117
+ var basePath = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData , Environment . SpecialFolderOption . Create ) ;
118
+ var TestDir = "TestIODir" ;
119
+ var dirPath = Path . Combine ( basePath , TestDir ) ;
120
+
121
+ var exists = _files . DirectoryExists ( dirPath ) ;
122
+ if ( exists )
123
+ {
124
+ _files . DeleteDirectory ( dirPath ) ;
125
+ exists = _files . DirectoryExists ( dirPath ) ;
126
+ }
127
+ // Comnfirm Starting State
128
+ exists . Should ( ) . BeFalse ( ) ;
129
+
130
+ // Create
131
+ _files . CreateDirectory ( dirPath ) ;
132
+ exists = _files . DirectoryExists ( dirPath ) ;
133
+
134
+ // Confim Creation
135
+ exists . Should ( ) . BeTrue ( ) ;
136
+
137
+ // CleanUp and Confim Delete
138
+ _files . DeleteDirectory ( dirPath ) ;
139
+ exists = _files . DirectoryExists ( dirPath ) ;
140
+ exists . Should ( ) . BeFalse ( ) ;
141
+ }
117
142
}
Original file line number Diff line number Diff line change 10
10
<Configurations >Debug;Release;NET7</Configurations >
11
11
<RootNamespace >Calebs.Extensions</RootNamespace >
12
12
<AssemblyName >Calebs.Extensions</AssemblyName >
13
- <Version >1.3.1 </Version >
13
+ <Version >1.4.0 </Version >
14
14
<GeneratePackageOnBuild >true</GeneratePackageOnBuild >
15
15
<Authors >Caleb Jenkins</Authors >
16
16
<Company >Caleb Jenkins</Company >
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ namespace Calebs.Extensions.SystemIO;
10
10
/// </summary>
11
11
public interface IFileIO
12
12
{
13
+ bool FileExists ( string path ) => File . Exists ( path ) ;
14
+ void DeleteFile ( string path ) => File . Delete ( path ) ;
15
+ string ReadAllText ( string path ) => File . ReadAllText ( path ) ;
16
+ void WriteAllLines ( string path , IEnumerable < string > lines ) => File . WriteAllLines ( path , lines ) ;
13
17
string [ ] GetFiles ( string path , string filter = "" ) => Directory . GetFiles ( path , filter ) ;
14
18
bool DirectoryExists ( string path ) => Directory . Exists ( path ) ;
15
19
string GetDirectoryName ( string path ) => Path . GetDirectoryName ( path ) ;
16
- string ReadAllText ( string path ) => File . ReadAllText ( path ) ;
17
- bool FileExists ( string path ) => File . Exists ( path ) ;
18
- void WriteAllLines ( string path , IEnumerable < string > lines ) => File . WriteAllLines ( path , lines ) ;
19
- void DeleteFile ( string path ) => File . Delete ( path ) ;
20
+ void CreateDirectory ( string path ) => Directory . CreateDirectory ( path ) ;
21
+ void DeleteDirectory ( string path ) => Directory . Delete ( path ) ;
20
22
}
You can’t perform that action at this time.
0 commit comments