mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-24 04:11:14 -10:00
* Remove TemporaryDirectory/File from FileSystem tests * Explicitly set UseShellExecute=false in MountHelper Commit migrated from https://github.com/dotnet/corefx/commit/a84b402d70d5720268649c4707ddb3152974fa08
90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
// 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.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using Xunit;
|
|
|
|
namespace System.IO.Tests
|
|
{
|
|
public class Directory_GetDirectories_str : Directory_GetFileSystemEntries_str
|
|
{
|
|
protected override bool TestFiles { get { return false; } }
|
|
protected override bool TestDirectories { get { return true; } }
|
|
|
|
public override string[] GetEntries(string path)
|
|
{
|
|
return Directory.GetDirectories(path);
|
|
}
|
|
|
|
[ConditionalFact(nameof(CanCreateSymbolicLinks))]
|
|
public void EnumerateWithSymLinkToDirectory()
|
|
{
|
|
DirectoryInfo containingFolder = Directory.CreateDirectory(GetTestFilePath());
|
|
|
|
// Test a symlink to a directory that does and then doesn't exist
|
|
DirectoryInfo targetDir = Directory.CreateDirectory(GetTestFilePath());
|
|
{
|
|
// Create a symlink to a folder that exists
|
|
string linkPath = Path.Combine(containingFolder.FullName, Path.GetRandomFileName());
|
|
Assert.True(MountHelper.CreateSymbolicLink(linkPath, targetDir.FullName, isDirectory: true));
|
|
|
|
Assert.True(Directory.Exists(linkPath));
|
|
Assert.Equal(1, GetEntries(containingFolder.FullName).Count());
|
|
}
|
|
targetDir.Delete(recursive: true);
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
Assert.Equal(1, GetEntries(containingFolder.FullName).Count());
|
|
Assert.Equal(0, Directory.GetFiles(containingFolder.FullName).Count());
|
|
}
|
|
else
|
|
{
|
|
// The target file is gone and the symlink still exists; since it can't be resolved,
|
|
// on Unix it's treated as a file rather than as a directory.
|
|
Assert.Equal(0, GetEntries(containingFolder.FullName).Count());
|
|
Assert.Equal(1, Directory.GetFiles(containingFolder.FullName).Count());
|
|
}
|
|
}
|
|
}
|
|
|
|
public class Directory_GetDirectories_str_str : Directory_GetFileSystemEntries_str_str
|
|
{
|
|
protected override bool TestFiles { get { return false; } }
|
|
protected override bool TestDirectories { get { return true; } }
|
|
|
|
public override string[] GetEntries(string path)
|
|
{
|
|
return Directory.GetDirectories(path, "*");
|
|
}
|
|
|
|
public override string[] GetEntries(string path, string searchPattern)
|
|
{
|
|
return Directory.GetDirectories(path, searchPattern);
|
|
}
|
|
}
|
|
|
|
public class Directory_GetDirectories_str_str_so : Directory_GetFileSystemEntries_str_str_so
|
|
{
|
|
protected override bool TestFiles { get { return false; } }
|
|
protected override bool TestDirectories { get { return true; } }
|
|
|
|
public override string[] GetEntries(string path)
|
|
{
|
|
return Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
|
|
}
|
|
|
|
public override string[] GetEntries(string path, string searchPattern)
|
|
{
|
|
return Directory.GetDirectories(path, searchPattern, SearchOption.TopDirectoryOnly);
|
|
}
|
|
|
|
public override string[] GetEntries(string path, string searchPattern, SearchOption option)
|
|
{
|
|
return Directory.GetDirectories(path, searchPattern, option);
|
|
}
|
|
}
|
|
}
|