Skip to content

IDirectoryInfoFactory.Wrap loses part of absolute path when used with MockFileSystem #1049

Description

@koyote

Describe the bug
If you provide the MockFileSystem's DirectoryInfo.Wrap method with a DirectoryInfo that has an absolute path, the resulting IDirectoryInfo has the wrong file path.

To Reproduce

usingXunit;usingSystem.IO.Abstractions;usingSystem.IO.Abstractions.TestingHelpers;[Fact]publicvoidTest(){varfs=newMockFileSystem();vardirectoryInfo=newDirectoryInfo(@"C:\subfolder\file");varwrappedDirectoryInfo=fs.DirectoryInfo.Wrap(directoryInfo);Assert.Equal(directoryInfo.FullName,wrappedDirectoryInfo.FullName);// wrappedDirectoryInfo returns "C:\file"}

Expected behaviour
The test above is expected to pass.

Actual behaviour

Assert.Equal() Failure
↓ (pos 3)
Expected: C:\subfolder\file
Actual: C:\file
↑ (pos 3)

Additional context
Tested on Windows 10, .Net 7, System.IO.Abstractions version 19.2.69

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testinghelpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onstate: releasedIssues that are releasedtype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions