@@ -0,0 +1,7 @@
+namespace ProcessFiles.Interfaces
+{
+ public interface IDirectory
+ {
+ public bool Exists(string? path);
+ }
+}
@@ -3,5 +3,6 @@
public interface IFileSystem
{
public IFile File { get; }
+ public IDirectory Directory { get; }
}
@@ -0,0 +1,10 @@
+using ProcessFiles.Interfaces;
+using System.IO;
+
+namespace ProcessFiles.Models
+ public class DefaultDirectory : IDirectory
+ public bool Exists(string? path) => Directory.Exists(path);
@@ -6,5 +6,8 @@ namespace ProcessFiles.Models
private readonly IFile file = new DefaultFile();
public IFile File => file;
+ private readonly IDirectory directory = new DefaultDirectory();
+ public IDirectory Directory => directory;
@@ -93,7 +93,7 @@ namespace ProcessFiles
private void ProcessDir(string path, string[] fileExtensions, Action<string> action, bool recursive = false)
- if (!Directory.Exists(path))
+ if (!fileSystem.Directory.Exists(path))
errors.Add($"{path} doesn't exist!");
return;