Skip to content

Commit

Permalink
Add test for GetFileSystemEntries with SearchOption
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Aug 22, 2022
1 parent 0db468c commit 9c17a48
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using System.Security.AccessControl;
Expand Down Expand Up @@ -956,6 +956,24 @@ public void MockDirectory_GetFileSystemEntries_Returns_Files_And_Directories()
Assert.AreEqual(testPath, entries.Last());
}

[Test]
public void MockDirectory_GetFileSystemEntries_ShouldNotReturnSubDirectory_WithSearchOption()
{
string testPath = XFS.Path(@"c:\foo\bar.txt");
string testDir = XFS.Path(@"c:\foo\bar");
string testSubDir = XFS.Path(@"c:\foo\bar\baz");
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ testPath, new MockFileData("Demo text content") },
{ testSubDir, new MockDirectoryData() },
});

var entries = fileSystem.Directory.GetFileSystemEntries(XFS.Path(@"c:\foo"), "*", SearchOption.TopDirectoryOnly).OrderBy(k => k);
Assert.AreEqual(2, entries.Count());
Assert.AreEqual(testDir, entries.First());
Assert.AreEqual(testPath, entries.Last());
}

[Test]
public void MockDirectory_GetFiles_ShouldThrowArgumentNullException_IfPathParamIsNull()
{
Expand Down

0 comments on commit 9c17a48

Please sign in to comment.