diff --git a/tests/System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs b/tests/System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs index 0ab2617e9..5b3bfdfc0 100644 --- a/tests/System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs +++ b/tests/System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Runtime.Versioning; using System.Security.AccessControl; @@ -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 + { + { 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() {