This project is read-only.
1
Vote

MockFileSystem - DirectoryInfoBase.GetDirectories() returns itself if case varies

description

The logic to return all directories doesn't recognize when a directory is itself if the case varies at all. Example code illustrating this below
    public void MockFileDirectoryBug()
    {
        MockFileSystem fs = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { @"c:\logs\myfile.txt", new MockFileData("foo") },
                { @"c:\logs\reports\myfile2.txt", new MockFileData("foo bar") },
                { @"c:\demo\jQuery.js", new MockFileData("bar") }
            });
        DirectoryInfoBase logDirectory = fs.DirectoryInfo.FromDirectoryName(@"C:\logs");
        foreach (var dir in logDirectory.GetDirectories())
        {
            if (string.Equals(dir.FullName, logDirectory.FullName, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new Exception("Returned same directory");
            }
        }
    }

comments