Ejemplo n.º 1
0
 public void DirectoryLongerThanMaxLongPath_DoesntThrow()
 {
     Assert.All((IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath())), (path) =>
     {
         Assert.False(Exists(path), path);
     });
 }
Ejemplo n.º 2
0
        public void DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException()
        {
            var paths = IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath(), useExtendedSyntax: true);

            Assert.All(paths, path =>
                       AssertExtensions.ThrowsAny <PathTooLongException, DirectoryNotFoundException>(() => Create(path)));
        }
Ejemplo n.º 3
0
 [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));
     });
 }
Ejemplo n.º 4
0
        [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));
            });
        }
Ejemplo n.º 5
0
        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)));
        }
Ejemplo n.º 6
0
 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));
     });
 }
Ejemplo n.º 7
0
        public void LongPath()
        {
            string testFileSource = Path.Combine(TestDirectory, GetTestFileName());

            File.Create(testFileSource).Dispose();

            Assert.All(IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath()), (path) =>
            {
                AssertExtensions.ThrowsAny <PathTooLongException, FileNotFoundException, DirectoryNotFoundException>(() => Move(testFileSource, path));
                File.Delete(testFileSource);
                AssertExtensions.ThrowsAny <PathTooLongException, FileNotFoundException, DirectoryNotFoundException>(() => Move(path, testFileSource));
            });
        }
Ejemplo n.º 8
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.GetPathsLongerThanMaxLongPath(GetTestFilePath()), (path) =>
            {
                Assert.Throws <PathTooLongException>(() => Move(testFileSource, path));
                File.Delete(testFileSource);
                Assert.Throws <PathTooLongException>(() => Move(path, testFileSource));
            });
        }
Ejemplo n.º 9
0
        public void DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException()
        {
            var paths = IOInputs.GetPathsLongerThanMaxLongPath(GetTestFilePath(), useExtendedSyntax: true);

            // Long directory path with extended syntax throws PathTooLongException on Desktop.
            // Everywhere else, it may be either PathTooLongException or DirectoryNotFoundException
            if (PlatformDetection.IsFullFramework)
            {
                Assert.All(paths, path => { Assert.Throws <PathTooLongException>(() => Create(path)); });
            }
            else
            {
                Assert.All(paths,
                           path =>
                {
                    AssertExtensions
                    .ThrowsAny <PathTooLongException, DirectoryNotFoundException>(
                        () => Create(path));
                });
            }
        }