diff --git a/PathLib.UnitTest.Posix/PathLib.UnitTest.Posix.csproj b/PathLib.UnitTest.Posix/PathLib.UnitTest.Posix.csproj
index b029bb4..56b454a 100644
--- a/PathLib.UnitTest.Posix/PathLib.UnitTest.Posix.csproj
+++ b/PathLib.UnitTest.Posix/PathLib.UnitTest.Posix.csproj
@@ -8,6 +8,7 @@
+
@@ -20,8 +21,8 @@
-
-
+
+
diff --git a/PathLib.UnitTest.Posix/PosixPathTests.cs b/PathLib.UnitTest.Posix/PosixPathTests.cs
index fcb6498..cf474d8 100644
--- a/PathLib.UnitTest.Posix/PosixPathTests.cs
+++ b/PathLib.UnitTest.Posix/PosixPathTests.cs
@@ -11,6 +11,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
+using FluentAssertions;
using Xunit.Sdk;
namespace PathLib.UnitTest.Posix;
@@ -47,7 +48,7 @@ public PosixPathTests(PosixPathTestsFixture fixture)
public void Stat_With_MissingFile_GivesError()
{
var path = new PosixPath(Path.Combine(_fixture.TempFolder, "does_not_exist"));
- Assert.False(path.Exists());
+ path.Exists().Should().BeFalse();
Assert.Throws(() => path.Stat());
}
diff --git a/PathLib.UnitTest.Windows/PathLib.UnitTest.Windows.csproj b/PathLib.UnitTest.Windows/PathLib.UnitTest.Windows.csproj
index e782fef..5f06f29 100644
--- a/PathLib.UnitTest.Windows/PathLib.UnitTest.Windows.csproj
+++ b/PathLib.UnitTest.Windows/PathLib.UnitTest.Windows.csproj
@@ -10,6 +10,7 @@
+
diff --git a/PathLib.UnitTest.Windows/WindowsPathTests.cs b/PathLib.UnitTest.Windows/WindowsPathTests.cs
index 7f53121..f2cdfb7 100644
--- a/PathLib.UnitTest.Windows/WindowsPathTests.cs
+++ b/PathLib.UnitTest.Windows/WindowsPathTests.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using FluentAssertions;
using Xunit;
using PathLib;
using Path = System.IO.Path;
@@ -88,9 +89,7 @@ public void ExpandUser_WithCustomHomeDirString_ExpandsDir()
var path = new WindowsPath("~/tmp");
var expected = homeDir.Join("tmp");
- var actual = path.ExpandUser(homeDir);
-
- Assert.Equal(expected, actual);
+ path.ExpandUser(homeDir).Should().Be(expected);
}
[Fact]
diff --git a/PathLib.UnitTest/PathLib.UnitTest.csproj b/PathLib.UnitTest/PathLib.UnitTest.csproj
index fc7ad3d..7f891c8 100644
--- a/PathLib.UnitTest/PathLib.UnitTest.csproj
+++ b/PathLib.UnitTest/PathLib.UnitTest.csproj
@@ -10,6 +10,7 @@
+
diff --git a/PathLib.UnitTest/PathUnitTest.cs b/PathLib.UnitTest/PathUnitTest.cs
index 726ef11..0e3fcdf 100644
--- a/PathLib.UnitTest/PathUnitTest.cs
+++ b/PathLib.UnitTest/PathUnitTest.cs
@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using FluentAssertions;
using Xunit;
namespace PathLib.UnitTest
@@ -93,7 +94,31 @@ public void Resolve_WithNoSymlinks_KeepsSamePath()
var actual = expected.Resolve();
Assert.Equal(expected, actual);
}
-
+
+ [Fact]
+ public void ListDir_with_pattern()
+ {
+ // Arrange
+ var tmpDir = Paths.Create(_fixture.TempFolder);
+ Assert.True(tmpDir.IsDir());
+
+ var file1 = tmpDir / "file1";
+ Assert.False(file1.IsFile());
+ file1.Open(FileMode.CreateNew).Dispose();
+ Assert.True(file1.IsFile());
+
+ var dir1 = tmpDir / "dir1";
+ Assert.False(dir1.IsDir());
+ dir1.Mkdir();
+ Assert.True(dir1.IsDir());
+
+ // Assertions
+ tmpDir.ListDir("non-existent").Should().BeEmpty();
+
+ tmpDir.ListDir("file*").Select(f => f.FileInfo.FullName).Should()
+ .BeEquivalentTo(file1.FileInfo.FullName);
+ }
+
// sym1 => ../../real2
// sym2 => ../real3
// sym3 => /abs/path/real2/absfile.txt
@@ -103,6 +128,5 @@ public void Resolve_WithNoSymlinks_KeepsSamePath()
// /real2/real4/anotherfile.txt
// /real2/absfile.txt
// /sym3
-
}
-}
+}
\ No newline at end of file
diff --git a/PathLib/ConcretePath.cs b/PathLib/ConcretePath.cs
index becda27..4eb5d72 100644
--- a/PathLib/ConcretePath.cs
+++ b/PathLib/ConcretePath.cs
@@ -149,7 +149,7 @@ public IEnumerable ListDir(string pattern, SearchOption scope)
{
throw new ArgumentException("Glob may only be called on directories.");
}
- foreach (var dir in DirectoryInfo.GetDirectories())
+ foreach (var dir in DirectoryInfo.GetDirectories(pattern, scope))
{
yield return PathFactory(dir.FullName);
}