Exemple #1
0
        [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");
            });
        }
Exemple #2
0
 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);
     });
 }
Exemple #4
0
        public void ExtendedDirectoryLongerThanLegacyMaxPathSucceeds()
        {
            var paths = IOInputs.GetPathsLongerThanMaxPath(useExtendedSyntax: true, includeExtendedMaxPath: false);

            Assert.All(paths, (path) =>
            {
                Assert.True(Create(path).Exists);
            });
        }
Exemple #5
0
        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));
     });
 }
Exemple #7
0
    public static void Exists_DirectoryLongerThanMaxPathAsPath_ReturnsFalse()
    {
        var paths = IOInputs.GetPathsLongerThanMaxPath();

        foreach (string path in paths)
        {
            bool result = Directory.Exists(path);

            Assert.False(result, path);
        }
    }
Exemple #8
0
        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));
            });
        }
Exemple #9
0
    public static void CreateDirectory_DirectoryLongerThanMaxPathAsPath_ThrowsPathTooLongException()
    {
        var paths = IOInputs.GetPathsLongerThanMaxPath();

        foreach (var path in paths)
        {
            Assert.Throws <PathTooLongException>(() =>
            {
                Directory.CreateDirectory(path);
            });
        }
    }
Exemple #10
0
        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));
            });
        }