Describe the bug
Calling MockFileSystem.Directory.GetDirectories(@"some\path") returns absolute paths instead of relative paths
To Reproduce
In this code
varmockFs=newMockFileSystem();mockFs.Directory.CreateDirectory(@"foo\bar");varoutput=mockFs.Directory.GetDirectories("foo");output is an array with a single string: C:\foo\bar, which is incorrect.
Expected behavior
In the same example, output should be an array with a single string foo\bar
Additional context
Here's a more comprehensive code snippet that shows:
- how the System.IO.Directory class behaves
- that FileSystem.Directory behaves correctly
- that MockFileSystem.Directory behaves incorrectly
[TestMethod]publicvoidDirectory_GetDirectories_Should_Return_Relative_Paths(){//This shows how the system classes behave : it returns one relative directoryDirectory.CreateDirectory(@"foo\bar");vardirs1=Directory.GetDirectories("foo");CollectionAssert.AreEqual(new[]{@"foo\bar"},dirs1);//passes//This shows that the real FileSystem behaves correctly, same as system classesvarfs=newFileSystem();vardirs2=fs.Directory.GetDirectories("foo");CollectionAssert.AreEqual(dirs1,dirs2);//passes//This shows that the MockFileSystem behaves incorrectly : it returns one absolute directory pathvarmockFs=newMockFileSystem();mockFs.Directory.CreateDirectory(@"foo\bar");vardirs3=mockFs.Directory.GetDirectories("foo");Console.WriteLine(dirs3[0]);// C:\foo\barCollectionAssert.AreEqual(dirs1,dirs3,"dirs3 should equal dirs1");//fails}
Describe the bug
Calling
MockFileSystem.Directory.GetDirectories(@"some\path")returns absolute paths instead of relative pathsTo Reproduce
In this code
outputis an array with a single string:C:\foo\bar, which is incorrect.Expected behavior
In the same example,
outputshould be an array with a single stringfoo\barAdditional context
Here's a more comprehensive code snippet that shows: