[PlatformSpecific(TestPlatforms.Windows)] // device name prefixes public void PathWithReservedDeviceNameAsExtendedPath() { var paths = IOInputs.GetReservedDeviceNames(); Assert.All(paths, (path) => { Assert.True(Create(IOInputs.ExtendedPrefix + Path.Combine(TestDirectory, path)).Exists, path); }); }
[PlatformSpecific(TestPlatforms.Windows)] // long directory path with extended syntax throws PathTooLongException public void DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsPathTooLongException() { var paths = IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath(), useExtendedSyntax: true); Assert.All(paths, (path) => { Assert.Throws <PathTooLongException>(() => Create(path)); }); }
[PlatformSpecific(TestPlatforms.Windows)] // long directory path with extended syntax succeeds public void ExtendedDirectoryLongerThanLegacyMaxPath_Succeeds() { var paths = IOInputs.GetPathsLongerThanMaxPath(GetTestFilePath(), useExtendedSyntax: true); Assert.All(paths, (path) => { Assert.True(Create(path).Exists); }); }
[PlatformSpecific(TestPlatforms.Windows)] // long directory path throws PathTooLongException public void DirectoryLongerThanMaxLongPath_ThrowsPathTooLongException() { var paths = IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath()); Assert.All(paths, (path) => { Assert.Throws <PathTooLongException>(() => Create(path)); }); }
[PlatformSpecific(PlatformID.Windows)] // device name prefixes public void PathWithReservedDeviceNameAsPath_ThrowsDirectoryNotFoundException() { // Throws DirectoryNotFoundException, when the behavior really should be an invalid path var paths = IOInputs.GetPathsWithReservedDeviceNames(); Assert.All(paths, (path) => { Assert.Throws <DirectoryNotFoundException>(() => Create(path)); }); }
public void DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException() { var paths = IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath(), useExtendedSyntax: true); // Ideally this should be PathTooLongException or DirectoryNotFoundException but on some machines // windows gives us ERROR_INVALID_NAME, producing IOException. Assert.All(paths, path => AssertExtensions.ThrowsAny <PathTooLongException, DirectoryNotFoundException, IOException>(() => Create(path))); }
[PlatformSpecific(PlatformID.Windows)] // UNC shares public void UncPathWithoutShareNameAsPath_ThrowsArgumentException() { var paths = IOInputs.GetUncPathsWithoutShareName(); foreach (var path in paths) { Assert.Throws <ArgumentException>(() => Create(path)); } }
public void PathWithInvalidCharactersAsPath_ThrowsArgumentException() { var paths = IOInputs.GetPathsWithInvalidCharacters(); Assert.All(paths, (path) => { Assert.Throws <ArgumentException>(() => Create(path)); }); }
[PlatformSpecific(PlatformID.Windows)] // alternate data streams public void PathWithAlternateDataStreams_ThrowsNotSupportedException() { var paths = IOInputs.GetPathsWithAlternativeDataStreams(); Assert.All(paths, (path) => { Assert.Throws <NotSupportedException>(() => Create(path)); }); }
public void WindowsWhiteSpaceAsPath_ThrowsArgumentException() { var paths = IOInputs.GetWhiteSpace(); Assert.All(paths, (path) => { Assert.Throws <ArgumentException>(() => Create(path)); }); }
public void PathWithInvalidColons_ThrowsNotSupportedException() { var paths = IOInputs.GetPathsWithInvalidColons(); Assert.All(paths, (path) => { Assert.Throws <NotSupportedException>(() => Create(path)); }); }
public void WindowsWhitespacePath() { FileInfo testFile = new FileInfo(GetTestFilePath()); Assert.All(IOInputs.GetWhiteSpace(), (whitespace) => { Assert.Throws <ArgumentException>(() => Move(testFile.FullName, whitespace)); }); }
public void ValidPathExists_ReturnsTrue() { Assert.All((IOInputs.GetValidPathComponentNames()), (component) => { string path = Path.Combine(TestDirectory, component); DirectoryInfo testDir = Directory.CreateDirectory(path); Assert.True(Exists(path)); }); }
public void DirectoryLongerThanMaxDirectoryAsPath_ThrowsPathTooLongException() { var paths = IOInputs.GetPathsLongerThanMaxDirectory(); Assert.All(paths, (path) => { Assert.Throws <PathTooLongException>(() => Create(path)); Directory.Delete(Path.Combine(Path.GetPathRoot(Directory.GetCurrentDirectory()), path.Split(Path.DirectorySeparatorChar)[1]), true); }); }
public void ValidPathExists_ReturnsTrue() { Assert.All((IOInputs.GetValidPathComponentNames()), (component) => { string path = Path.Combine(TestDirectory, component); FileInfo testFile = new FileInfo(path); testFile.Create().Dispose(); Assert.True(Exists(path)); }); }
public void PathWithIllegalCharacters() { FileInfo testFile = new FileInfo(GetTestFilePath()); testFile.Create().Dispose(); Assert.All(IOInputs.GetPathsWithInvalidCharacters(), (invalid) => { Assert.Throws <ArgumentException>(() => Move(testFile.FullName, invalid)); }); }
[PlatformSpecific(PlatformID.Windows)] // In Windows, trailing whitespace in a path is trimmed public void TrimTrailingWhitespacePath() { FileInfo testFile = new FileInfo(GetTestFilePath()); testFile.Create().Dispose(); Assert.All((IOInputs.GetWhiteSpace()), (component) => { Assert.True(Exists(testFile.FullName + component)); // string concat in case Path.Combine() trims whitespace before Exists gets to it }); }
public void WindowsPathWithIllegalColons() { FileInfo testFile = new FileInfo(GetTestFilePath()); testFile.Create().Dispose(); Assert.All(IOInputs.GetPathsWithInvalidColons(), (invalid) => { Assert.Throws <NotSupportedException>(() => Move(testFile.FullName, invalid)); }); }
public void UnixWhiteSpaceAsPath_Allowed() { var paths = IOInputs.GetWhiteSpace(); Assert.All(paths, (path) => { Create(Path.Combine(TestDirectory, path)); Assert.True(Directory.Exists(Path.Combine(TestDirectory, path))); }); }
[PlatformSpecific(TestPlatforms.Windows)] // long directory path succeeds public void DirectoryLongerThanMaxDirectoryAsPath_Succeeds() { var paths = IOInputs.GetPathsLongerThanMaxDirectory(GetTestFilePath()); Assert.All(paths, (path) => { var result = Create(path); Assert.True(Directory.Exists(result.FullName)); }); }
public void Path_Longer_Than_MaxLongPath_Throws_Exception() { string testDir = GetTestFilePath(); Directory.CreateDirectory(testDir); Assert.All((IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath())), (path) => { Assert.Throws<PathTooLongException>(() => Move(testDir, path)); Assert.Throws<PathTooLongException>(() => Move(path, testDir)); }); }
public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsPathTooLongException() { // While paths themselves can be up to 260 characters including trailing null, file systems // limit each components of the path to a total of 255 characters. var paths = IOInputs.GetPathsWithComponentLongerThanMaxComponent(); Assert.All(paths, (path) => { Assert.Throws <PathTooLongException>(() => Create(path)); }); }
public static void Exists_NonSignificantWhiteSpaceAsPath_ReturnsFalse() { var paths = IOInputs.GetNonSignificantTrailingWhiteSpace(); foreach (string path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
public static void Exists_DirectoryLongerThanMaxPathAsPath_ReturnsFalse() { var paths = IOInputs.GetPathsLongerThanMaxPath(); foreach (string path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
public static void Exists_NonExistentValidPathAsPath_ReturnsFalse() { var paths = IOInputs.GetValidPathComponentNames(); foreach (string path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
[PlatformSpecific(PlatformID.Windows)] // UNC paths public static void Exists_UncPathWithoutShareNameAsPath_ReturnsFalse() { var paths = IOInputs.GetUncPathsWithoutShareName(); foreach (string path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
[PlatformSpecific(PlatformID.Windows)] // device names public static void Exists_PathWithReservedDeviceNameAsPath_ReturnsFalse() { var paths = IOInputs.GetPathsWithReservedDeviceNames(); foreach (var path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
[PlatformSpecific(PlatformID.Windows)] // alternate data stream public static void Exists_PathWithAlternativeDataStreams_ReturnsFalse() { var paths = IOInputs.GetPathsWithAlternativeDataStreams(); foreach (var path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
public static void Exists_PathWithInvalidCharactersAsPath_ReturnsFalse() { var paths = IOInputs.GetPathsWithInvalidCharacters(); foreach (string path in paths) { bool result = Directory.Exists(path); Assert.False(result, path); } }
public void PathWithInvalidCharactersAsPath_ReturnsFalse() { // Checks that errors aren't thrown when calling Exists() on paths with impossible to create characters Assert.All((IOInputs.GetPathsWithInvalidCharacters()), (component) => { Assert.False(Exists(component)); }); Assert.False(Exists("..")); Assert.False(Exists(".")); }