示例#1
0
        [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);
            });
        }
示例#2
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));
            });
        }
示例#3
0
        [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);
            });
        }
示例#4
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));
            });
        }
示例#5
0
        [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));
            });
        }
示例#6
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)));
        }
示例#7
0
        [PlatformSpecific(PlatformID.Windows)] // UNC shares
        public void UncPathWithoutShareNameAsPath_ThrowsArgumentException()
        {
            var paths = IOInputs.GetUncPathsWithoutShareName();

            foreach (var path in paths)
            {
                Assert.Throws <ArgumentException>(() => Create(path));
            }
        }
示例#8
0
        public void PathWithInvalidCharactersAsPath_ThrowsArgumentException()
        {
            var paths = IOInputs.GetPathsWithInvalidCharacters();

            Assert.All(paths, (path) =>
            {
                Assert.Throws <ArgumentException>(() => Create(path));
            });
        }
示例#9
0
        [PlatformSpecific(PlatformID.Windows)] // alternate data streams
        public void PathWithAlternateDataStreams_ThrowsNotSupportedException()
        {
            var paths = IOInputs.GetPathsWithAlternativeDataStreams();

            Assert.All(paths, (path) =>
            {
                Assert.Throws <NotSupportedException>(() => Create(path));
            });
        }
示例#10
0
        public void WindowsWhiteSpaceAsPath_ThrowsArgumentException()
        {
            var paths = IOInputs.GetWhiteSpace();

            Assert.All(paths, (path) =>
            {
                Assert.Throws <ArgumentException>(() => Create(path));
            });
        }
示例#11
0
        public void PathWithInvalidColons_ThrowsNotSupportedException()
        {
            var paths = IOInputs.GetPathsWithInvalidColons();

            Assert.All(paths, (path) =>
            {
                Assert.Throws <NotSupportedException>(() => Create(path));
            });
        }
示例#12
0
        public void WindowsWhitespacePath()
        {
            FileInfo testFile = new FileInfo(GetTestFilePath());

            Assert.All(IOInputs.GetWhiteSpace(), (whitespace) =>
            {
                Assert.Throws <ArgumentException>(() => Move(testFile.FullName, whitespace));
            });
        }
示例#13
0
 public void ValidPathExists_ReturnsTrue()
 {
     Assert.All((IOInputs.GetValidPathComponentNames()), (component) =>
     {
         string path           = Path.Combine(TestDirectory, component);
         DirectoryInfo testDir = Directory.CreateDirectory(path);
         Assert.True(Exists(path));
     });
 }
示例#14
0
        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);
            });
        }
示例#15
0
 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));
     });
 }
示例#16
0
        public void PathWithIllegalCharacters()
        {
            FileInfo testFile = new FileInfo(GetTestFilePath());

            testFile.Create().Dispose();
            Assert.All(IOInputs.GetPathsWithInvalidCharacters(), (invalid) =>
            {
                Assert.Throws <ArgumentException>(() => Move(testFile.FullName, invalid));
            });
        }
示例#17
0
        [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
            });
        }
示例#18
0
        public void WindowsPathWithIllegalColons()
        {
            FileInfo testFile = new FileInfo(GetTestFilePath());

            testFile.Create().Dispose();
            Assert.All(IOInputs.GetPathsWithInvalidColons(), (invalid) =>
            {
                Assert.Throws <NotSupportedException>(() => Move(testFile.FullName, invalid));
            });
        }
示例#19
0
        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)));
            });
        }
示例#20
0
        [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));
            });
        }
示例#21
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));
     });
 }
示例#22
0
        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));
            });
        }
示例#23
0
    public static void Exists_NonSignificantWhiteSpaceAsPath_ReturnsFalse()
    {
        var paths = IOInputs.GetNonSignificantTrailingWhiteSpace();

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

            Assert.False(result, path);
        }
    }
示例#24
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);
        }
    }
示例#25
0
    public static void Exists_NonExistentValidPathAsPath_ReturnsFalse()
    {
        var paths = IOInputs.GetValidPathComponentNames();

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

            Assert.False(result, path);
        }
    }
示例#26
0
    [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);
        }
    }
示例#27
0
    [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);
        }
    }
示例#28
0
    [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);
        }
    }
示例#29
0
    public static void Exists_PathWithInvalidCharactersAsPath_ReturnsFalse()
    {
        var paths = IOInputs.GetPathsWithInvalidCharacters();

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

            Assert.False(result, path);
        }
    }
示例#30
0
        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("."));
        }