From 52dfaaf342856cf2e338dcbaa2c7ec216716374f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 21 Aug 2024 11:41:47 +0100 Subject: [PATCH] File enumeration not always deterministic on all OSs --- .../IO/DirectoryInfoTests.cs | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/DNX.Extensions.Tests/IO/DirectoryInfoTests.cs b/tests/DNX.Extensions.Tests/IO/DirectoryInfoTests.cs index 8d57ebe..d06cc40 100644 --- a/tests/DNX.Extensions.Tests/IO/DirectoryInfoTests.cs +++ b/tests/DNX.Extensions.Tests/IO/DirectoryInfoTests.cs @@ -76,7 +76,7 @@ public void FindFiles_for_single_pattern_without_recursion_finds_expected_files( // Assert result.Should().NotBeNull(); result.Count().Should().Be(1); - result.First().Name.Should().Be("file.txt"); + result.Count(x => x.Name == "file.txt").Should().Be(1); } [Fact] @@ -91,9 +91,9 @@ public void FindFiles_for_single_pattern_with_recursion_finds_expected_files() // Assert result.Should().NotBeNull(); result.Count().Should().Be(3); - result.First().Name.Should().Be("file.txt"); - result.Skip(1).First().Name.Should().Be("file1.txt"); - result.Skip(2).First().Name.Should().Be("file2.txt"); + result.Count(x => x.Name == "file.txt").Should().Be(1); + result.Count(x => x.Name == "file1.txt").Should().Be(1); + result.Count(x => x.Name == "file2.txt").Should().Be(1); } [Fact] @@ -109,8 +109,8 @@ public void FindFiles_for_multiple_patterns_without_recursion_finds_expected_fil // Assert result.Should().NotBeNull(); result.Count().Should().Be(2); - result.First().Name.Should().Be("file.txt"); - result.Skip(1).First().Name.Should().Be("file.json"); + result.Count(x => x.Name == "file.txt").Should().Be(1); + result.Count(x => x.Name == "file.json").Should().Be(1); } [Fact] @@ -126,12 +126,12 @@ public void FindFiles_for_multiple_patterns_with_recursion_finds_expected_files( // Assert result.Should().NotBeNull(); result.Count().Should().Be(6); - result.First().Name.Should().Be("file.txt"); - result.Skip(1).First().Name.Should().Be("file1.txt"); - result.Skip(2).First().Name.Should().Be("file2.txt"); - result.Skip(3).First().Name.Should().Be("file.json"); - result.Skip(4).First().Name.Should().Be("file1.json"); - result.Skip(5).First().Name.Should().Be("file2.json"); + result.Count(x => x.Name == "file.txt").Should().Be(1); + result.Count(x => x.Name == "file1.txt").Should().Be(1); + result.Count(x => x.Name == "file2.txt").Should().Be(1); + result.Count(x => x.Name == "file.json").Should().Be(1); + result.Count(x => x.Name == "file1.json").Should().Be(1); + result.Count(x => x.Name == "file2.json").Should().Be(1); } [Fact] @@ -161,8 +161,8 @@ public void FindDirectories_for_single_pattern_without_recursion_finds_expected_ // Assert result.Should().NotBeNull(); result.Count().Should().Be(2); - result.First().Name.Should().Be("dir1"); - result.Skip(1).First().Name.Should().Be("dir2"); + result.Count(x => x.Name == "dir1").Should().Be(1); + result.Count(x => x.Name == "dir2").Should().Be(1); } [Fact] @@ -177,10 +177,10 @@ public void FindDirectories_for_single_pattern_with_recursion_finds_expected_fil // Assert result.Should().NotBeNull(); result.Count().Should().Be(4); - result.First().Name.Should().Be("dir1"); - result.Skip(1).First().Name.Should().Be("dir2"); - result.Skip(2).First().Name.Should().Be("dur3"); - result.Skip(3).First().Name.Should().Be("dur4"); + result.Count(x => x.Name == "dir1").Should().Be(1); + result.Count(x => x.Name == "dir2").Should().Be(1); + result.Count(x => x.Name == "dur3").Should().Be(1); + result.Count(x => x.Name == "dur4").Should().Be(1); } [Fact] @@ -195,8 +195,8 @@ public void FindDirectories_for_multiple_patterns_without_recursion_finds_expect // Assert result.Should().NotBeNull(); result.Count().Should().Be(2); - result.First().Name.Should().Be("dir1"); - result.Skip(1).First().Name.Should().Be("dir2"); + result.Count(x => x.Name == "dir1").Should().Be(1); + result.Count(x => x.Name == "dir2").Should().Be(1); } [Fact] @@ -211,10 +211,10 @@ public void FindDirectories_for_multiple_patterns_with_recursion_finds_expected_ // Assert result.Should().NotBeNull(); result.Count().Should().Be(4); - result.First().Name.Should().Be("dir1"); - result.Skip(1).First().Name.Should().Be("dir2"); - result.Skip(2).First().Name.Should().Be("dur3"); - result.Skip(3).First().Name.Should().Be("dur4"); + result.Count(x => x.Name == "dir1").Should().Be(1); + result.Count(x => x.Name == "dir2").Should().Be(1); + result.Count(x => x.Name == "dur3").Should().Be(1); + result.Count(x => x.Name == "dur4").Should().Be(1); } [Theory]