diff --git a/src/System.IO.Abstractions.TestingHelpers/MockFileSystem.cs b/src/System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
index f6acf0117..3d821a30e 100644
--- a/src/System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
+++ b/src/System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using System.Reflection;
@@ -9,7 +8,7 @@ namespace System.IO.Abstractions.TestingHelpers
///
[Serializable]
- public class MockFileSystem : IFileSystem, IMockFileDataAccessor
+ public class MockFileSystem : FileSystemBase, IMockFileDataAccessor
{
private const string DEFAULT_CURRENT_DIRECTORY = @"C:\";
private const string TEMP_DIRECTORY = @"C:\temp";
@@ -69,21 +68,21 @@ public MockFileSystem(IDictionary files, string currentDir
///
public StringOperations StringOperations { get; }
///
- public IFile File { get; }
+ public override IFile File { get; }
///
- public IDirectory Directory { get; }
+ public override IDirectory Directory { get; }
///
- public IFileInfoFactory FileInfo { get; }
+ public override IFileInfoFactory FileInfo { get; }
///
- public IFileStreamFactory FileStream { get; }
+ public override IFileStreamFactory FileStream { get; }
///
- public IPath Path { get; }
+ public override IPath Path { get; }
///
- public IDirectoryInfoFactory DirectoryInfo { get; }
+ public override IDirectoryInfoFactory DirectoryInfo { get; }
///
- public IDriveInfoFactory DriveInfo { get; }
+ public override IDriveInfoFactory DriveInfo { get; }
///
- public IFileSystemWatcherFactory FileSystemWatcher { get; set; }
+ public override IFileSystemWatcherFactory FileSystemWatcher { get; }
///
public IFileSystem FileSystem => this;
///
diff --git a/src/System.IO.Abstractions/FileSystem.cs b/src/System.IO.Abstractions/FileSystem.cs
index e3feed1e8..59210dc04 100644
--- a/src/System.IO.Abstractions/FileSystem.cs
+++ b/src/System.IO.Abstractions/FileSystem.cs
@@ -2,7 +2,7 @@
{
///
[Serializable]
- public class FileSystem : IFileSystem
+ public class FileSystem : FileSystemBase
{
///
public FileSystem()
@@ -18,27 +18,27 @@ public FileSystem()
}
///
- public IDirectory Directory { get; }
+ public override IDirectory Directory { get; }
///
- public IFile File { get; }
+ public override IFile File { get; }
///
- public IFileInfoFactory FileInfo { get; }
+ public override IFileInfoFactory FileInfo { get; }
///
- public IFileStreamFactory FileStream { get; }
+ public override IFileStreamFactory FileStream { get; }
///
- public IPath Path { get; }
+ public override IPath Path { get; }
///
- public IDirectoryInfoFactory DirectoryInfo { get; }
+ public override IDirectoryInfoFactory DirectoryInfo { get; }
///
- public IDriveInfoFactory DriveInfo { get; }
+ public override IDriveInfoFactory DriveInfo { get; }
///
- public IFileSystemWatcherFactory FileSystemWatcher { get; }
+ public override IFileSystemWatcherFactory FileSystemWatcher { get; }
}
}
diff --git a/src/System.IO.Abstractions/FileSystemBase.cs b/src/System.IO.Abstractions/FileSystemBase.cs
new file mode 100644
index 000000000..30ac14234
--- /dev/null
+++ b/src/System.IO.Abstractions/FileSystemBase.cs
@@ -0,0 +1,31 @@
+namespace System.IO.Abstractions
+{
+ ///
+ [Serializable]
+ public abstract class FileSystemBase : IFileSystem
+ {
+ ///
+ public abstract IDirectory Directory { get; }
+
+ ///
+ public abstract IFile File { get; }
+
+ ///
+ public abstract IFileInfoFactory FileInfo { get; }
+
+ ///
+ public abstract IFileStreamFactory FileStream { get; }
+
+ ///
+ public abstract IPath Path { get; }
+
+ ///
+ public abstract IDirectoryInfoFactory DirectoryInfo { get; }
+
+ ///
+ public abstract IDriveInfoFactory DriveInfo { get; }
+
+ ///
+ public abstract IFileSystemWatcherFactory FileSystemWatcher { get; }
+ }
+}
diff --git a/tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs b/tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs
index 2ba329375..57a8aa3ca 100644
--- a/tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs
+++ b/tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs
@@ -393,23 +393,24 @@ public void MockFileSystem_DefaultState_DefaultTempDirectoryExists()
}
[Test]
- public void MockFileSystem_FileSystemWatcher_PathShouldBeAssignable()
+ public void MockFileSystem_FileSystemWatcher_Can_Be_Overridden()
{
var path = XFS.Path(@"C:\root");
- var fileSystem = new MockFileSystem { FileSystemWatcher = new TestFileSystemWatcherFactory() };
+ var fileSystem = new TestFileSystem(new TestFileSystemWatcherFactory());
var watcher = fileSystem.FileSystemWatcher.CreateNew(path);
Assert.AreEqual(path, watcher.Path);
}
- [Test]
- public void MockFileSystem_FileSystemWatcher_PathAndFilterShouldBeAssignable()
+ private class TestFileSystem : MockFileSystem
{
- var path = XFS.Path(@"C:\root");
- var filter = "*.txt";
- var fileSystem = new MockFileSystem { FileSystemWatcher = new TestFileSystemWatcherFactory() };
- var watcher = fileSystem.FileSystemWatcher.CreateNew(path, filter);
- Assert.AreEqual(path, watcher.Path);
- Assert.AreEqual(filter, watcher.Filter);
+ private readonly IFileSystemWatcherFactory fileSystemWatcherFactory;
+
+ public TestFileSystem(IFileSystemWatcherFactory fileSystemWatcherFactory)
+ {
+ this.fileSystemWatcherFactory = fileSystemWatcherFactory;
+ }
+
+ public override IFileSystemWatcherFactory FileSystemWatcher => fileSystemWatcherFactory;
}
private class TestFileSystemWatcherFactory : IFileSystemWatcherFactory
diff --git a/version.json b/version.json
index bb8d6cc6c..8acbd42f7 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "15.0",
+ "version": "16.0",
"assemblyVersion": {
"precision": "major"
},