Describe the bug
Mock FileInfo.Delete does not consider the MockFileData.AllowedFileShare property during the delete operation. Similar to #747, but on the FileInfo interface.
To Reproduce
The following test reproduces the error:
[Test]publicvoidMockFileInfo_Delete_ShouldThrowIfFileAccessShareHasNoWriteOrDeleteAccess(){// ArrangevarfileSystem=newMockFileSystem(newDictionary<string,MockFileData>(StringComparer.OrdinalIgnoreCase){{@"c:\bar\foo.txt",newMockFileData("some demo content"){AllowedFileShare=System.IO.FileShare.None}},{@"c:\bar\baz.txt",newMockFileData("some demo content"){AllowedFileShare=System.IO.FileShare.None}},});// Throws exception, as expectedAssert.Throws(typeof(System.IO.IOException),()=>fileSystem.File.Delete(@"c:\bar\baz.txt"));varfi=fileSystem.FileInfo.FromFileName(@"c:\bar\foo.txt");// Does not throw exception, but shouldAssert.Throws(typeof(System.IO.IOException),()=>fi.Delete());}Expected behavior
As the AllowedFileShare is set to NONE, an exception should be throw when the delete is attempted.
Thanks!
Describe the bug
Mock FileInfo.Delete does not consider the MockFileData.AllowedFileShare property during the delete operation. Similar to #747, but on the FileInfo interface.
To Reproduce
The following test reproduces the error:
Expected behavior
As the AllowedFileShare is set to NONE, an exception should be throw when the delete is attempted.
Thanks!