Skip to content

Commit

Permalink
Modfiy ErrorHandlingTests for Browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Hwang committed Aug 11, 2020
1 parent 7a2671a commit ad2f5a9
Showing 1 changed file with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,40 +101,40 @@ public void DeleteDirectoryAfterOpening()
}
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)]
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
[Fact]
public void VariableLengthFileNames_AllCreatableFilesAreEnumerable()
{
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));
}
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
var names = new List<string>();

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)]
public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable()
{
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
var names = new List<string>();
var lengthCap = PlatformDetection.IsBrowser ? 256 : 10_000; // On Browser NAME_MAX is 255, otherwise arbitrarily large limit for the test
for (int length = 1; length < lengthCap; length++)
{
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));
}

for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test
[Fact]
public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable()
{
string name = new string('a', length);
try { Directory.CreateDirectory(Path.Join(testDirectory.FullName, name)); }
catch { break; }
names.Add(name);
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
var names = new List<string>();

var lengthCap = PlatformDetection.IsBrowser ? 256 : 10_000; // On Browser NAME_MAX is 255, otherwise arbitrarily large limit for the test
for (int length = 1; length < lengthCap; length++)
{
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));
}
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));
}
}
}

0 comments on commit ad2f5a9

Please sign in to comment.