Skip to content

Bug: DirectoryInfoMock.Parent return wrong parent #842

@klace92

Description

@klace92

Hi found a bug where "DirectoryInfoMock.Parent" return wrong parent compared to the system API. I narrow it down to the file path has ending "\" like this "C:\SomeStorage\". This problem is seen on a unittest target Net framework. Here is some sample code.

[TestMethod]
public void Test()
{
    var d = new DirectoryInfo($"C:\\SomeStorage\\");
    Console.WriteLine($"Filesystem parent {d.Parent.FullName}"); // this write out "C:\"
    var fs = new MockFileSystem();
    this.storageDirectory = this.fileSystem.DirectoryInfo.New(d.FullName); 
    Console.WriteLine($"Mock parent {storageDirectory.Parent.FullName}"); // this write out "C:\SomeStorage"
}

I think the problem is with

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions