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:
Diffstat (limited to 'src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs')
-rw-r--r--src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs37
1 files changed, 37 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
index e4c85d831e..60bc3d9224 100644
--- a/src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs
+++ b/src/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.netcoreapp.cs
@@ -2,6 +2,9 @@
// 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;
+using System.Collections.Generic;
+using System.Linq;
using System.IO.Enumeration;
using Xunit;
@@ -96,5 +99,39 @@ namespace System.IO.Tests
Assert.Equal(info.FullName, ie.DirectoryFinished);
}
}
+
+ [Fact]
+ public void VariableLengthFileNames_AllCreatableFilesAreEnumerable()
+ {
+ DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
+ var names = new List<string>();
+
+ for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test
+ {
+ string name = new string('a', length);
+ try { File.Create(Path.Join(testDirectory.FullName, name)).Dispose(); }
+ catch { break; }
+ names.Add(name);
+ }
+ Assert.InRange(names.Count, 1, int.MaxValue);
+ Assert.Equal(names.OrderBy(n => n), Directory.GetFiles(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n));
+ }
+
+ [Fact]
+ public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable()
+ {
+ DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
+ var names = new List<string>();
+
+ for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test
+ {
+ string name = new string('a', length);
+ try { Directory.CreateDirectory(Path.Join(testDirectory.FullName, name)); }
+ catch { break; }
+ names.Add(name);
+ }
+ Assert.InRange(names.Count, 1, int.MaxValue);
+ Assert.Equal(names.OrderBy(n => n), Directory.GetDirectories(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n));
+ }
}
}