using Explorer.Domain; using Explorer.Domain.Abstractions; using Explorer.FileOperations; namespace Explorer.FileOperations.Tests; public class FileOperationTests { [Fact] public void New_folder_and_rename_on_real_filesystem() { var root = Path.Combine(Path.GetTempPath(), "ew-ops", Guid.NewGuid().ToString("N")); Directory.CreateDirectory(root); try { var ops = new FileOperationService(null!, new StubShell(), new StubEnum()); var created = ops.NewFolder(root); Assert.True(Directory.Exists(created)); ops.Rename(created, "Renamed"); Assert.True(Directory.Exists(Path.Combine(root, "Renamed"))); } finally { try { Directory.Delete(root, true); } catch { /* ignore */ } } } } file sealed class StubEnum : IFileSystemEnumerator { public IEnumerable EnumerateChildren(string directoryPath) => []; public IReadOnlyList EnumerateChildrenSafe(string directoryPath, out string? error) { error = null; return []; } public FileSystemItem? GetItem(string path) => null; } file sealed class StubShell : IShellFileOperations { public void Open(string path) { } public bool DeleteToRecycleBin(IReadOnlyList paths, out string? error) => Delete(paths, true, out error); public bool Delete(IReadOnlyList paths, bool recycle, out string? error) { error = "n/a"; return false; } public bool CopyFileWithProgress(string source, string destination, bool overwrite, IProgress? progress, CancellationToken cancellationToken, out string? error) { error = "n/a"; return false; } public bool MoveFileWithProgress(string source, string destination, bool overwrite, IProgress? progress, CancellationToken cancellationToken, out string? error) { error = "n/a"; return false; } public bool CreateShortcut(string targetPath, string shortcutPath, out string? error) { error = null; return true; } }