Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>2018-02-22 06:32:31 +0300
committerGitHub <noreply@github.com>2018-02-22 06:32:31 +0300
commit62878f34d65f8bac6f7ebd91083fb9a02866de98 (patch)
tree9dab9892e6d21f4e90132e427fdd573726f6a6d4 /src/System.IO.FileSystem/tests
parentad34249a15a8d93f9517283b00c863fb6f8c152a (diff)
Make final API review changes to file enumeration (#27318)
* Make final API review changes to file enumeration Tweak stack array initialization to just zero the first element in matcher algorithm. cc: @danmosemsft @terrajobst * Don't null out the native name to track conversion
Diffstat (limited to 'src/System.IO.FileSystem/tests')
-rw-r--r--src/System.IO.FileSystem/tests/Enumeration/AttributeTests.netcoreapp.cs26
-rw-r--r--src/System.IO.FileSystem/tests/Enumeration/PatternTransformTests.netcoreapp.cs2
-rw-r--r--src/System.IO.FileSystem/tests/Enumeration/Win32MatcherTests.netcoreapp.cs (renamed from src/System.IO.FileSystem/tests/Enumeration/DosMatcherTests.netcoreapp.cs)12
-rw-r--r--src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj2
4 files changed, 34 insertions, 8 deletions
diff --git a/src/System.IO.FileSystem/tests/Enumeration/AttributeTests.netcoreapp.cs b/src/System.IO.FileSystem/tests/Enumeration/AttributeTests.netcoreapp.cs
index d35783713f..2ba62dfb42 100644
--- a/src/System.IO.FileSystem/tests/Enumeration/AttributeTests.netcoreapp.cs
+++ b/src/System.IO.FileSystem/tests/Enumeration/AttributeTests.netcoreapp.cs
@@ -2,6 +2,7 @@
// 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 Xunit;
@@ -111,5 +112,30 @@ namespace System.IO.Tests.Enumeration
Assert.False(enumerator.MoveNext());
}
}
+
+ [Fact]
+ public void IsHiddenAttribute()
+ {
+ DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
+ FileInfo fileOne = new FileInfo(Path.Combine(testDirectory.FullName, GetTestFileName()));
+
+ // Put a period in front to make it hidden on Unix
+ FileInfo fileTwo = new FileInfo(Path.Combine(testDirectory.FullName, "." + GetTestFileName()));
+
+ fileOne.Create().Dispose();
+ fileTwo.Create().Dispose();
+ if (PlatformDetection.IsWindows)
+ fileTwo.Attributes = fileTwo.Attributes | FileAttributes.Hidden;
+
+ IEnumerable<string> enumerable = new FileSystemEnumerable<string>(
+ testDirectory.FullName,
+ (ref FileSystemEntry entry) => entry.ToFullPath(),
+ new EnumerationOptions() { AttributesToSkip = 0 })
+ {
+ ShouldIncludePredicate = (ref FileSystemEntry entry) => entry.IsHidden
+ };
+
+ Assert.Equal(new string[] { fileTwo.FullName }, enumerable);
+ }
}
}
diff --git a/src/System.IO.FileSystem/tests/Enumeration/PatternTransformTests.netcoreapp.cs b/src/System.IO.FileSystem/tests/Enumeration/PatternTransformTests.netcoreapp.cs
index d9e8b5330d..9cb33e5853 100644
--- a/src/System.IO.FileSystem/tests/Enumeration/PatternTransformTests.netcoreapp.cs
+++ b/src/System.IO.FileSystem/tests/Enumeration/PatternTransformTests.netcoreapp.cs
@@ -32,7 +32,7 @@ namespace System.IO.Tests.Enumeration
string[] results = GetFiles(testDirectory.FullName, pattern);
FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileTwo.FullName }, results);
- results = GetFiles(testDirectory.FullName, pattern, new EnumerationOptions { MatchType = MatchType.Dos });
+ results = GetFiles(testDirectory.FullName, pattern, new EnumerationOptions { MatchType = MatchType.Win32 });
FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileTwo.FullName }, results);
}
diff --git a/src/System.IO.FileSystem/tests/Enumeration/DosMatcherTests.netcoreapp.cs b/src/System.IO.FileSystem/tests/Enumeration/Win32MatcherTests.netcoreapp.cs
index 508f0f6bf9..bc1d529969 100644
--- a/src/System.IO.FileSystem/tests/Enumeration/DosMatcherTests.netcoreapp.cs
+++ b/src/System.IO.FileSystem/tests/Enumeration/Win32MatcherTests.netcoreapp.cs
@@ -7,15 +7,15 @@ using Xunit;
namespace System.IO.Tests
{
- public class DosMatcherTests
+ public class Win32MatcherTests
{
- [Theory, MemberData(nameof(DosMatchData)), MemberData(nameof(EscapedDosMatchData))]
- public static void DosMatch(string expression, string name, bool ignoreCase, bool expected)
+ [Theory, MemberData(nameof(Win32MatchData)), MemberData(nameof(EscapedWin32MatchData))]
+ public static void Win32Match(string expression, string name, bool ignoreCase, bool expected)
{
- Assert.Equal(expected, FileSystemName.MatchesDosExpression(expression, name.AsSpan(), ignoreCase));
+ Assert.Equal(expected, FileSystemName.MatchesWin32Expression(expression, name.AsSpan(), ignoreCase));
}
- public static TheoryData<string, string, bool, bool> EscapedDosMatchData => new TheoryData<string, string, bool, bool>
+ public static TheoryData<string, string, bool, bool> EscapedWin32MatchData => new TheoryData<string, string, bool, bool>
{
// Trailing escape matches as it is considered "invisible"
{ "\\", "\\", false, true },
@@ -43,7 +43,7 @@ namespace System.IO.Tests
{ "\\\"", "\"", true, true },
};
- public static TheoryData<string, string, bool, bool> DosMatchData => new TheoryData<string, string, bool, bool>
+ public static TheoryData<string, string, bool, bool> Win32MatchData => new TheoryData<string, string, bool, bool>
{
{ null, "", false, false },
{ null, "", true, false },
diff --git a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
index 672d5642dc..5ff308577c 100644
--- a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
+++ b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
@@ -56,7 +56,7 @@
<Compile Include="Enumeration\ConstructionTests.netcoreapp.cs" />
<Compile Include="Enumeration\SpecialDirectoryTests.netcoreapp.cs" />
<Compile Include="Enumeration\SkipAttributeTests.netcoreapp.cs" />
- <Compile Include="Enumeration\DosMatcherTests.netcoreapp.cs" />
+ <Compile Include="Enumeration\Win32MatcherTests.netcoreapp.cs" />
<Compile Include="Enumeration\MatchCasingTests.netcoreapp.cs" />
<Compile Include="Enumeration\TrimmedPaths.netcoreapp.cs" />
<Compile Include="Enumeration\ErrorHandlingTests.netcoreapp.cs" />