-
-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
Description
Hi I running this in unittest under net framework and I notis that creating a folder trought MockFileSystem -> Directory -> CreateDirectory is miss behaving compared to normal filesytem access. Here is sample code
[TestMethod]
public void Test()
{
var fullPath = Path.Combine( Directory.GetCurrentDirectory(), "Test");
var path = $"{fullPath}\\1.02.03.04\\;
var path2 = $"{fullPath}\\1.02.03.05\\;
Directory.CreateDirectory(path);
Directory.CreateDirectory(path2);
var result = Directory.GetDirectories(fullPath)
.Select(x => Path.GetFileName(x))
.ToList();
var fs = new MockFileSystem();
fs.Directory.CreateDirectory(path);
fs.Directory.CreateDirectory(path2);
var result2 = fs.Directory.GetDirectories(fullPath)
.Select(x => fs.Path.GetFileName(x))
.ToList();
Assert.IsTrue(result.SequenceEqual(result2), $"From system: {string.Join(", ", result)}. From mock {string.Join(", ", result2)}");
}
The result form this is
Assert.IsTrue failed. From system: 1.02.03.04, 1.02.03.05. From mock ,
The result2 contains two item but both is empty strings. If I'm remove the trailing "\" from "path" and "path2" it return correct item but order is reversed.