[PlatformSpecific(TestPlatforms.Windows)] // Path longer than max path limit public void OverMaxPathWorks_Windows() { // Create a destination path longer than the traditional Windows limit of 256 characters, // but under the long path limitation (32K). string testFileSource = Path.Combine(TestDirectory, GetTestFileName()); File.Create(testFileSource).Dispose(); Assert.True(File.Exists(testFileSource), "test file should exist"); Assert.All(IOInputs.GetPathsLongerThanMaxPath(GetTestFilePath()), (path) => { string baseDestinationPath = Path.GetDirectoryName(path); if (!Directory.Exists(baseDestinationPath)) { Directory.CreateDirectory(baseDestinationPath); } Assert.True(Directory.Exists(baseDestinationPath), "base destination path should exist"); Move(testFileSource, path); Assert.True(File.Exists(path), "moved test file should exist"); File.Delete(testFileSource); Assert.False(File.Exists(testFileSource), "source test file should not exist"); Move(path, testFileSource); Assert.True(File.Exists(testFileSource), "restored test file should exist"); }); }
public void DirectoryLongerThanMaxPathAsPath_DoesntThrow() { Assert.All((IOInputs.GetPathsLongerThanMaxPath(GetTestFilePath())), (path) => { Assert.False(Exists(path), 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); }); }
public void ExtendedDirectoryLongerThanLegacyMaxPathSucceeds() { var paths = IOInputs.GetPathsLongerThanMaxPath(useExtendedSyntax: true, includeExtendedMaxPath: false); Assert.All(paths, (path) => { Assert.True(Create(path).Exists); }); }
public void DirectoryLongerThanMaxPathAsPath_ThrowsPathTooLongException() { var paths = IOInputs.GetPathsLongerThanMaxPath(); Assert.All(paths, (path) => { Assert.Throws <PathTooLongException>(() => Create(path)); }); }
[PlatformSpecific(TestPlatforms.Windows)] // long directory path succeeds public void DirectoryLongerThanMaxPath_Succeeds() { var paths = IOInputs.GetPathsLongerThanMaxPath(GetTestFilePath()); Assert.All(paths, (path) => { DirectoryInfo result = Create(path); Assert.True(Directory.Exists(result.FullName)); }); }
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 void Path_Longer_Than_MaxPath_Throws_Exception() { string testDir = GetTestFilePath(); Directory.CreateDirectory(testDir); Assert.All((IOInputs.GetPathsLongerThanMaxPath()), (path) => { Assert.Throws <PathTooLongException>(() => Move(testDir, path)); Assert.Throws <PathTooLongException>(() => Move(path, testDir)); }); }
public static void CreateDirectory_DirectoryLongerThanMaxPathAsPath_ThrowsPathTooLongException() { var paths = IOInputs.GetPathsLongerThanMaxPath(); foreach (var path in paths) { Assert.Throws <PathTooLongException>(() => { Directory.CreateDirectory(path); }); } }
public void LongPath() { //Create a destination path longer than the traditional Windows limit of 256 characters string testFileSource = Path.Combine(TestDirectory, GetTestFileName()); File.Create(testFileSource).Dispose(); Assert.All(IOInputs.GetPathsLongerThanMaxPath(), (path) => { Assert.Throws <PathTooLongException>(() => Move(testFileSource, path)); File.Delete(testFileSource); Assert.Throws <PathTooLongException>(() => Move(path, testFileSource)); }); }