forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API tweaks to match latest updates to spec
Add a few new tests See #25873
- Loading branch information
1 parent
b9b5b80
commit 2cd65df
Showing
10 changed files
with
124 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/System.IO.FileSystem/tests/Enumeration/IncludePredicateTests.netcoreapp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.IO.Enumeration; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace System.IO.Tests.Enumeration | ||
{ | ||
public abstract class IncludePredicateTests : FileSystemTest | ||
{ | ||
public static IEnumerable<string> GetFileFullPathsWithExtension(string directory, | ||
bool recursive, params string[] extensions) | ||
{ | ||
return new FileSystemEnumerable<string>( | ||
directory, | ||
(ref FileSystemEntry entry) => entry.ToFullPath(), | ||
new EnumerationOptions() { RecurseSubdirectories = recursive }) | ||
{ | ||
ShouldIncludePredicate = (ref FileSystemEntry entry) => | ||
{ | ||
if (entry.IsDirectory) return false; | ||
foreach (string extension in extensions) | ||
{ | ||
if (Path.GetExtension(entry.FileName).EndsWith(extension)) | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; | ||
} | ||
|
||
[Fact] | ||
public void MatchCase() | ||
{ | ||
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); | ||
DirectoryInfo testSubdirectory = Directory.CreateDirectory(Path.Combine(testDirectory.FullName, "Subdirectory")); | ||
FileInfo fileOne = new FileInfo(Path.Combine(testDirectory.FullName, "fileone.htm")); | ||
FileInfo fileTwo = new FileInfo(Path.Combine(testDirectory.FullName, "filetwo.html")); | ||
FileInfo fileThree = new FileInfo(Path.Combine(testSubdirectory.FullName, "filethree.doc")); | ||
FileInfo fileFour = new FileInfo(Path.Combine(testSubdirectory.FullName, "filefour.docx")); | ||
|
||
fileOne.Create().Dispose(); | ||
fileTwo.Create().Dispose(); | ||
fileThree.Create().Dispose(); | ||
fileFour.Create().Dispose(); | ||
|
||
string[] paths = GetFileFullPathsWithExtension(testDirectory.FullName, true, ".htm", ".doc").ToArray(); | ||
|
||
FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileThree.FullName }, paths); | ||
} | ||
} | ||
} |
Oops, something went wrong.