Esempio n. 1
0
        public void LongPathExtendedDirectory()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(IOServices.GetPath(IOInputs.ExtendedPrefix + TestDirectory, characterCount: 500));

            Delete(testDir.FullName);
            Assert.False(testDir.Exists);
        }
Esempio n. 2
0
 [PlatformSpecific(TestPlatforms.AnyUnix)] // long directory path allowed
 public void UnixPathLongerThan256_Allowed()
 {
     DirectoryInfo testDir = Create(GetTestFilePath());
     string path = IOServices.GetPath(testDir.FullName, 257);
     DirectoryInfo result = Create(path);
     Assert.Equal(path, result.FullName);
     Assert.True(Directory.Exists(result.FullName));
 }
Esempio n. 3
0
        public void UnixPathLongerThan256_Allowed()
        {
            DirectoryInfo testDir = Create(GetTestFilePath());
            PathInfo      path    = IOServices.GetPath(testDir.FullName, 257, IOInputs.MaxComponent);
            DirectoryInfo result  = Create(path.FullPath);

            Assert.Equal(path.FullPath, result.FullName);
            Assert.True(Directory.Exists(result.FullName));
        }
Esempio n. 4
0
        public void DirectoryEqualToMaxDirectory_CanBeCreatedAllAtOnce()
        {
            DirectoryInfo testDir = Create(GetTestFilePath());
            PathInfo      path    = IOServices.GetPath(testDir.FullName, IOInputs.MaxDirectory, maxComponent: 10);
            DirectoryInfo result  = Create(path.FullPath);

            Assert.Equal(path.FullPath, result.FullName);
            Assert.True(Directory.Exists(result.FullName));
        }
Esempio n. 5
0
        [PlatformSpecific(TestPlatforms.Windows)] // max directory length not fixed on Unix
        public void DirectoryEqualToMaxDirectory_ReturnsTrue()
        {
            // Creates directories up to the maximum directory length all at once
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            string        path    = IOServices.GetPath(testDir.FullName, IOInputs.MaxDirectory);

            Directory.CreateDirectory(path);
            Assert.True(Exists(path));
        }
Esempio n. 6
0
    [PlatformSpecific(PlatformID.Windows)] // max directory length not fixed on Unix
    public static void CreateDirectory_DirectoryEqualToMaxDirectory_CanBeCreatedAllAtOnce()
    {                                      // Creates directories up to the maximum directory length all at once
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            PathInfo path = IOServices.GetPath(directory.Path, IOInputs.MaxDirectory, maxComponent: 10);

            DirectoryInfo result = Directory.CreateDirectory(path.FullPath);

            Assert.Equal(path.FullPath, result.FullName);
            Assert.True(Directory.Exists(result.FullName));
        }
    }
Esempio n. 7
0
        public void DirectoryEqualToMaxDirectory_CanBeCreated()
        {
            DirectoryInfo testDir = Create(GetTestFilePath());
            PathInfo      path    = IOServices.GetPath(testDir.FullName, IOInputs.MaxDirectory, IOInputs.MaxComponent);

            Assert.All(path.SubPaths, (subpath) =>
            {
                DirectoryInfo result = Create(subpath);

                Assert.Equal(subpath, result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            });
        }
Esempio n. 8
0
    [PlatformSpecific(PlatformID.Windows)] // max directory length not fixed on Unix
    public static void Exists_DirectoryEqualToMaxDirectory_ReturnsTrue()
    {                                      // Creates directories up to the maximum directory length all at once
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            PathInfo path = IOServices.GetPath(directory.Path, IOInputs.MaxDirectory, maxComponent: 10);

            Directory.CreateDirectory(path.FullPath);

            bool result = Directory.Exists(path.FullPath);

            Assert.True(result, path.FullPath);
        }
    }
Esempio n. 9
0
        [PlatformSpecific(TestPlatforms.Windows)]  // Valid Windows path extended prefix, long path
        public void ValidCreation_LongPathExtendedSyntax()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(IOServices.GetPath(IOInputs.ExtendedPrefix + TestDirectory, characterCount: 500));

            Assert.StartsWith(IOInputs.ExtendedPrefix, testDir.FullName);
            string testFile = Path.Combine(testDir.FullName, GetTestFileName());

            using (FileStream stream = Create(testFile))
            {
                Assert.True(File.Exists(testFile));
                Assert.Equal(0, stream.Length);
                Assert.Equal(0, stream.Position);
            }
        }
Esempio n. 10
0
    [PlatformSpecific(PlatformID.Windows)] // max directory length not fixed on Unix
    public static void CreateDirectory_DirectoryEqualToMaxDirectory_CanBeCreated()
    {                                      // Recursively creates directories right up to the maximum directory length ("247 chars not including null")
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            PathInfo path = IOServices.GetPath(directory.Path, IOInputs.MaxDirectory, IOInputs.MaxComponent);

            // First create 'C:\AAA...AA', followed by 'C:\AAA...AAA\AAA...AAA', etc
            foreach (string subpath in path.SubPaths)
            {
                DirectoryInfo result = Directory.CreateDirectory(subpath);

                Assert.Equal(subpath, result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            }
        }
    }
Esempio n. 11
0
        public void EnumerateFilesDirectoryOverLegacyMaxPath()
        {
            // Check enumerating when the entire path is over MAX_PATH

            string directory = IOServices.GetPath(GetTestFilePath(), 270);

            Assert.Equal(270, directory.Length);
            Assert.True(Directory.CreateDirectory(directory).Exists);

            for (int i = 0; i < 6; i++)
            {
                string testFile = Path.Combine(directory, new string((char)('0' + i), i + 7));
                File.Create(testFile).Dispose();
            }

            string[] files = GetEntries(directory);
            Assert.Equal(6, files.Length);
        }
Esempio n. 12
0
        public void EnumerateFilesOverLegacyMaxPath()
        {
            // We want to test that directories under the legacy MAX_PATH (260 characters, including the null) can iterate files
            // even if the full path is over 260.

            string directory = IOServices.GetPath(GetTestFilePath(), 250);

            Assert.Equal(250, directory.Length);
            Assert.True(Directory.CreateDirectory(directory).Exists);

            for (int i = 0; i < 6; i++)
            {
                string testFile = Path.Combine(directory, new string((char)('0' + i), i + 7));
                File.Create(testFile).Dispose();
            }

            string[] files = GetEntries(directory);
            Assert.Equal(6, files.Length);
        }
Esempio n. 13
0
 private static string GetLongPath(string rootPath, int characterCount, bool extended = false)
 {
     return(IOServices.GetPath(rootPath, characterCount, extended));
 }
Esempio n. 14
0
 private static string GetLongPath(int characterCount, bool extended = false)
 {
     return(IOServices.GetPath(characterCount, extended).FullPath);
 }
Esempio n. 15
0
 private static string GetLongPath(int characterCount)
 {
     return(IOServices.GetPath(characterCount).FullPath);
 }