public void TestDirectorySpecial() { var fs = new PhysicalFileSystem(); // CreateDirectory Assert.True(fs.DirectoryExists("/")); if (IsWindows) { var directories = fs.EnumerateDirectories("/").ToList(); Assert.Equal(new List <UPath>() { "/mnt" }, directories); var drives = fs.EnumerateDirectories("/mnt").ToList(); Assert.True(drives.Count > 0); var allDrives = DriveInfo.GetDrives().Select(d => d.Name[0].ToString().ToLowerInvariant()).ToList(); var driveNames = drives.Select(d => d.GetName()).ToList(); Assert.Equal(allDrives, driveNames); Assert.True(fs.DirectoryExists("/")); Assert.True(fs.DirectoryExists("/mnt")); Assert.True(fs.DirectoryExists(drives[0])); var files = fs.EnumerateFiles("/").ToList(); Assert.True(files.Count == 0); files = fs.EnumerateFiles("/mnt").ToList(); Assert.True(files.Count == 0); var paths = fs.EnumeratePaths("/").ToList(); Assert.Equal(new List <UPath>() { "/mnt" }, paths); } }
public void TestEnumerate() { var fs = new PhysicalFileSystem(); var path = fs.ConvertPathFromInternal(SystemPath); var files = fs.EnumerateFiles(path).Select(p => fs.ConvertPathToInternal(p)).ToList(); var expectedfiles = Directory.EnumerateFiles(SystemPath).ToList(); Assert.Equal(expectedfiles, files); var dirs = fs.EnumerateDirectories(path / "../../..").Select(p => fs.ConvertPathToInternal(p)).ToList(); var expecteddirs = Directory.EnumerateDirectories(Path.GetFullPath(Path.Combine(SystemPath, "..\\..\\.."))).ToList(); Assert.Equal(expecteddirs, dirs); var paths = fs.EnumeratePaths(path / "../..").Select(p => fs.ConvertPathToInternal(p)).ToList(); var expectedPaths = Directory.EnumerateFileSystemEntries(Path.GetFullPath(Path.Combine(SystemPath, "..\\.."))).ToList(); Assert.Equal(expectedPaths, paths); }