Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestingHelpers: Directory.Move operates on files with a related name #664

Closed
meisenring opened this issue Oct 31, 2020 · 1 comment · Fixed by #665
Closed

TestingHelpers: Directory.Move operates on files with a related name #664

meisenring opened this issue Oct 31, 2020 · 1 comment · Fixed by #665
Labels
area: testinghelpers Issues that address the testing helpers state: in work Issues that are currently worked on type: bug Issues that describe misbehaving functionality

Comments

@meisenring
Copy link
Contributor

Describe the bug
Windows user here. I suspect this is a bug in the testing helpers?

Directory.Move operates on files with a related name.:

- source (dir)
    - dummy (dir)
        - content.txt (file)
    - dummy.txt (file)
- destination (dir)

Moving /source/dummy to /destination/dummy will produce the following:

- source (dir)
- destination (dir)
    - dummy (dir)
        - content.txt (file)
    - dummy.txt (file)

What I expected:

- source (dir)
    - dummy.txt (file) <-- not moved
- destination (dir)
    - dummy (dir)
        - content.txt (file)

To Reproduce
Steps to reproduce the behavior:

[Test]
public void MockDirectory_Move_ShouldOnlyMoveDirAndFilesWithinDir()
{
    var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
    {
        // Directory to move and its content:
        {XFS.Path(@"c:\source\dummy"), new MockDirectoryData()},
        {XFS.Path(@"c:\source\dummy\content.txt"), new MockFileData(new byte[] {0})},

        // Unrelated file, not in directory to move, but with a similar name:
        {XFS.Path(@"c:\source\dummy.txt"), new MockFileData(new byte[] {0})},

        // Destination of directory move operation:
        {XFS.Path(@"c:\destination"), new MockDirectoryData()},
    });

    fileSystem.Directory.Move(@"c:\source\dummy", @"c:\destination\dummy");

    Assert.That(fileSystem.FileExists(@"c:\source\dummy.txt"), Is.True);
}

Very cool library 👍

@meisenring meisenring added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Oct 31, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.87. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

meisenring pushed a commit to meisenring/System.IO.Abstractions that referenced this issue Oct 31, 2020
@fgreinacher fgreinacher added area: testinghelpers Issues that address the testing helpers state: in work Issues that are currently worked on and removed state: needs discussion Issues that need further discussion labels Nov 3, 2020
fgreinacher added a commit that referenced this issue Nov 26, 2020
Fixes #664 

Co-authored-by: Marco Eisenring <Marco.Eisenring@advellence.com>
Co-authored-by: Florian Greinacher <fgreinacher@users.noreply.github.com>
Co-authored-by: Florian Greinacher <florian@greinacher.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testinghelpers Issues that address the testing helpers state: in work Issues that are currently worked on type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants