Closed
Description
Describe the bug
File.Move behavior is different in MockFileSystem and physical FileSystem.
To Reproduce
The test below is green with real FileSystem, but MockFileSystem throws System.UnauthorizedAccessException : Access to the path 'C:\any.txt' is denied.
[Test]
public void Move_a_readonly_file()
{
//arrange
//IFileSystem fileSystem = new FileSystem();
IFileSystem fileSystem = new MockFileSystem();
var file = "any.txt";
fileSystem.File.WriteAllText(file, "foo");
//act
fileSystem.File.SetAttributes(file, FileAttributes.ReadOnly);
fileSystem.File.Move(file, file+".moved");
//assert
Assert.That(fileSystem.File.Exists(file+".moved"));
Assert.That(fileSystem.File.Exists(file), Is.False);
}
Additional context
Tested with
Dotnet SDK: 8.0.404
Package I use:
TargetFramework: net48
Windows I use: Windows11 Ver:10.0.22631 Build 22631