diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/IMockFileDataAccessor.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/IMockFileDataAccessor.cs
index 69958077c..ba479cdd8 100644
--- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/IMockFileDataAccessor.cs
+++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/IMockFileDataAccessor.cs
@@ -31,8 +31,12 @@ public interface IMockFileDataAccessor : IFileSystem
MockDriveData GetDrive(string name);
///
+ /// Adds the file.
///
- void AddFile(string path, MockFileData mockFile);
+ /// The path of the file to add.
+ /// The file data to add.
+ /// Flag indicating if the access conditions should be verified.
+ void AddFile(string path, MockFileData mockFile, bool verifyAccess = true);
///
///
@@ -58,10 +62,11 @@ public interface IMockFileDataAccessor : IFileSystem
/// Removes the file.
///
/// The file to remove.
+ /// Flag indicating if the access conditions should be verified.
///
/// The file must not exist.
///
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
///
/// Determines whether the file exists.
diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.cs
index 839b96e1d..92b5a6530 100644
--- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.cs
+++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFile.cs
@@ -546,8 +546,8 @@ public override void Move(string sourceFileName, string destFileName)
}
VerifyDirectoryExists(destFileName);
- mockFileDataAccessor.RemoveFile(sourceFileName);
- mockFileDataAccessor.AddFile(destFileName, mockFileDataAccessor.AdjustTimes(new MockFileData(sourceFile), TimeAdjustments.LastAccessTime));
+ mockFileDataAccessor.RemoveFile(sourceFileName, false);
+ mockFileDataAccessor.AddFile(destFileName, mockFileDataAccessor.AdjustTimes(new MockFileData(sourceFile), TimeAdjustments.LastAccessTime), false);
}
#if FEATURE_FILE_MOVE_WITH_OVERWRITE
diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
index 6169ec66a..8b1b620a2 100644
--- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
+++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
@@ -225,7 +225,7 @@ private void SetEntry(string path, MockFileData mockFile)
}
///
- public void AddFile(string path, MockFileData mockFile)
+ public void AddFile(string path, MockFileData mockFile, bool verifyAccess = true)
{
var fixedPath = FixPath(path, true);
@@ -237,7 +237,7 @@ public void AddFile(string path, MockFileData mockFile)
var isReadOnly = (file.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
var isHidden = (file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
- if (isReadOnly || isHidden)
+ if (verifyAccess && (isReadOnly || isHidden))
{
throw CommonExceptions.AccessDenied(path);
}
@@ -294,9 +294,10 @@ public void AddDirectory(IDirectoryInfo path)
///
/// An representing the path of the new file to add.
/// The data to use for the contents of the new file.
- public void AddFile(IFileInfo path, MockFileData data)
+ /// Flag indicating if the access conditions should be verified.
+ public void AddFile(IFileInfo path, MockFileData data, bool verifyAccess = true)
{
- AddFile(path.FullName, data);
+ AddFile(path.FullName, data, verifyAccess);
path.Refresh();
}
@@ -444,13 +445,13 @@ bool PathStartsWith(string path, string[] minMatch)
}
///
- public void RemoveFile(string path)
+ public void RemoveFile(string path, bool verifyAccess = true)
{
path = FixPath(path);
lock (files)
{
- if (FileExists(path) && (FileIsReadOnly(path) || Directory.Exists(path) && AnyFileIsReadOnly(path)))
+ if (FileExists(path) && verifyAccess && (FileIsReadOnly(path) || Directory.Exists(path) && AnyFileIsReadOnly(path)))
{
throw CommonExceptions.AccessDenied(path);
}
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net472.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net472.txt
index 296433506..89a7a39b9 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net472.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net472.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -360,8 +360,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -371,7 +371,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net6.0.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net6.0.txt
index 0717900dd..0328840c9 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net6.0.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net6.0.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -415,8 +415,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -426,7 +426,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net8.0.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net8.0.txt
index 9e09e1b04..afe51c603 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net8.0.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net8.0.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -439,8 +439,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -450,7 +450,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net9.0.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net9.0.txt
index 309c132cb..f99dc339c 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net9.0.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_net9.0.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -453,8 +453,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -464,7 +464,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.0.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.0.txt
index 84b1fef74..2470a7417 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.0.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.0.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -360,8 +360,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -371,7 +371,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.1.txt b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.1.txt
index 30ac2b613..eaaaad028 100644
--- a/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.1.txt
+++ b/tests/TestableIO.System.IO.Abstractions.Api.Tests/Expected/TestableIO.System.IO.Abstractions.TestingHelpers_netstandard2.1.txt
@@ -13,7 +13,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.StringOperations StringOperations { get; }
void AddDirectory(string path);
void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive);
- void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile);
+ void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true);
void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath);
System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments);
@@ -21,7 +21,7 @@ namespace System.IO.Abstractions.TestingHelpers
System.IO.Abstractions.TestingHelpers.MockDriveData GetDrive(string name);
System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path);
void MoveDirectory(string sourcePath, string destPath);
- void RemoveFile(string path);
+ void RemoveFile(string path, bool verifyAccess = true);
}
[System.Serializable]
public class MockDirectory : System.IO.Abstractions.DirectoryBase
@@ -388,8 +388,8 @@ namespace System.IO.Abstractions.TestingHelpers
public void AddDrive(string name, System.IO.Abstractions.TestingHelpers.MockDriveData mockDrive) { }
public void AddEmptyFile(System.IO.Abstractions.IFileInfo path) { }
public void AddEmptyFile(string path) { }
- public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data) { }
- public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile) { }
+ public void AddFile(System.IO.Abstractions.IFileInfo path, System.IO.Abstractions.TestingHelpers.MockFileData data, bool verifyAccess = true) { }
+ public void AddFile(string path, System.IO.Abstractions.TestingHelpers.MockFileData mockFile, bool verifyAccess = true) { }
public void AddFileFromEmbeddedResource(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public void AddFilesFromEmbeddedNamespace(string path, System.Reflection.Assembly resourceAssembly, string embeddedResourcePath) { }
public System.IO.Abstractions.TestingHelpers.MockFileData AdjustTimes(System.IO.Abstractions.TestingHelpers.MockFileData fileData, System.IO.Abstractions.TestingHelpers.TimeAdjustments timeAdjustments) { }
@@ -399,7 +399,7 @@ namespace System.IO.Abstractions.TestingHelpers
public System.IO.Abstractions.TestingHelpers.MockFileData GetFile(string path) { }
public System.IO.Abstractions.TestingHelpers.MockFileSystem MockTime(System.Func dateTimeProvider) { }
public void MoveDirectory(string sourcePath, string destPath) { }
- public void RemoveFile(string path) { }
+ public void RemoveFile(string path, bool verifyAccess = true) { }
}
public class MockFileSystemOptions
{
diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileMoveTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileMoveTests.cs
index 54a8881c7..0305c7b1e 100644
--- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileMoveTests.cs
+++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileMoveTests.cs
@@ -28,7 +28,7 @@ public async Task MockFile_Move_ShouldMoveFileWithinMemoryFileSystem()
}
[Test]
- public async Task MockFile_Move_WithReadOnlyAttribute_ShouldThrowUnauthorizedAccessExceptionAndNotMoveFile()
+ public async Task MockFile_Move_WithReadOnlyAttribute_ShouldMoveFile()
{
var sourceFilePath = @"c:\foo.txt";
var destFilePath = @"c:\bar.txt";
@@ -36,10 +36,10 @@ public async Task MockFile_Move_WithReadOnlyAttribute_ShouldThrowUnauthorizedAcc
fileSystem.File.WriteAllText(sourceFilePath, "this is some content");
fileSystem.File.SetAttributes(sourceFilePath, FileAttributes.ReadOnly);
- await That(() => fileSystem.File.Move(sourceFilePath, destFilePath)).Throws();
+ fileSystem.File.Move(sourceFilePath, destFilePath);
- await That(fileSystem.File.Exists(sourceFilePath)).IsEqualTo(true);
- await That(fileSystem.File.Exists(destFilePath)).IsEqualTo(false);
+ await That(fileSystem.File.Exists(destFilePath)).IsTrue();
+ await That(fileSystem.File.Exists(sourceFilePath)).IsFalse();
}
[Test]