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-13 00:56:17 +0300
committerGitHub <noreply@github.com>2018-02-13 00:56:17 +0300
commitc9100ffc2988a0faf0e92898762a445ccb3c0e13 (patch)
treef77f54ae8959ba60acfed3312d80979e059583fd /src/System.IO.FileSystem/tests
parentefcb7c2bfa98941d641c59187cdab721ada625db (diff)
Switch from using SafeHandle for Unix enumeration (#27052)
* Switch from using SafeHandle for Unix enumeration * Address feedback * Fix faceplant, dispose in test.
Diffstat (limited to 'src/System.IO.FileSystem/tests')
-rw-r--r--src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs43
-rw-r--r--src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj1
2 files changed, 44 insertions, 0 deletions
diff --git a/src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs b/src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs
new file mode 100644
index 0000000000..24f07f8911
--- /dev/null
+++ b/src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs
@@ -0,0 +1,43 @@
+// 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.IO.Enumeration;
+using Xunit;
+
+namespace System.IO.Tests
+{
+ public class ErrorHandlingTests : FileSystemTest
+ {
+ private class IgnoreErrors : FileSystemEnumerator<string>
+ {
+ public IgnoreErrors(string directory)
+ : base(directory)
+ { }
+
+ public int ErrorCount { get; private set; }
+
+ protected override string TransformEntry(ref FileSystemEntry entry)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override bool ContinueOnError(int error)
+ {
+ ErrorCount++;
+ return true;
+ }
+ }
+
+ [Fact]
+ public void OpenErrorDoesNotHappenAgainOnMoveNext()
+ {
+ using (IgnoreErrors ie = new IgnoreErrors(Path.GetRandomFileName()))
+ {
+ Assert.Equal(1, ie.ErrorCount);
+ Assert.False(ie.MoveNext());
+ Assert.Equal(1, ie.ErrorCount);
+ }
+ }
+ }
+}
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 471bf4cd52..63a4b2c7cf 100644
--- a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
+++ b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
@@ -59,6 +59,7 @@
<Compile Include="Enumeration\DosMatcherTests.netcoreapp.cs" />
<Compile Include="Enumeration\MatchCasingTests.netcoreapp.cs" />
<Compile Include="Enumeration\TrimmedPaths.netcoreapp.cs" />
+ <Compile Include="Enumeration\ErrorHandlingTests.netcoreapp.cs" />
</ItemGroup>
<ItemGroup>
<!-- Rewritten -->