Skip to content

Bug try deleting a Readonly directory from MockFileSystem dosn't throw any exception #853

@klace92

Description

@klace92

On Net framework deleting a readonly direcotroy from MockFileSystem dons't thrown any error. Look into the source code here you send only in 3 parameters

https://github.com/Testably/Testably.Abstractions/blob/f764c5ce5d401cf85ae6af7685501004b46a47ed/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs#L172C3-L182C4

But RequestAccess can take up to 7 but the one wonder about is "ignoreMetadataErrors" so default to true meaning this row will never trigger

https://github.com/Testably/Testably.Abstractions/blob/main/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs#L189

I quick test on real filsystem shows that this should throw "IOException". Here is the sample

        [TestMethod]
        public void Test()
        {
            var fs = new MockFileSystem();
            var path = Path.Combine(Directory.GetCurrentDirectory(),"Testad");
            var d = fs.Directory.CreateDirectory(path);
            // var d = Directory.CreateDirectory(path);
            d.Attributes = System.IO.FileAttributes.ReadOnly;
            d.Refresh();
            d.Delete(true); // This thrown IOException on real filesystem
        }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions