Skip to content

MockDirectory.Delete(string path, bool recursive) deletes all directories that starts with the same path. #428

@andjor

Description

@andjor

It seems that there is a bug in MockDirectory.Delete. The method deletes all directories that starts with the same path. I have included a small linqpad script to reproduce this.

var folder1Path = @"D:\Test\Program";
var folder2Path = @"D:\Test\Program_bak";
var folder3Path = @"D:\Test\Program_old";

var fileSystem = new MockFileSystem();

fileSystem.AddDirectory(folder1Path);
fileSystem.AddDirectory(folder2Path);
fileSystem.AddDirectory(folder3Path);

fileSystem.AllDirectories.Dump("Before");
fileSystem.Directory.Delete(folder1Path, recursive: true);
fileSystem.AllDirectories.Dump("After");

This results in all three folders being deleted. Tested with version 3.0.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: in workIssues that are currently worked ontype: 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