[PlatformSpecific(TestPlatforms.AnyUnix)]  // Trailing whitespace in path treated as significant
        public void UnixNonSignificantTrailingWhiteSpace(string component)
        {
            // Unix treats trailing/prename whitespace as significant and a part of the name.
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            string        path   = IOServices.RemoveTrailingSlash(testDir.Name) + component;
            DirectoryInfo result = new DirectoryInfo(TestDirectory).CreateSubdirectory(path);

            Assert.True(Directory.Exists(result.FullName));
            Assert.NotEqual(testDir.FullName, IOServices.RemoveTrailingSlash(result.FullName));
        }
Esempio n. 2
0
        public void WindowsControWhiteSpace()
        {
            // CreateSubdirectory will throw when passed a path with control whitespace e.g. "\t"
            var components = IOInputs.GetControlWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path = IOServices.RemoveTrailingSlash(GetTestFileName());
                Assert.Throws <ArgumentException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(component));
            });
        }
Esempio n. 3
0
    public static void Exists_ExistingDirectoryWithoutTrailingSlashAsPath_ReturnsTrue()
    {
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            string path = IOServices.RemoveTrailingSlash(directory.Path);

            bool result = Directory.Exists(path);

            Assert.True(result);
        }
    }
Esempio n. 4
0
    public static void Exists_FileWithoutTrailingSlashAsPath_ReturnsFalse()
    {
        using (TemporaryFile file = new TemporaryFile())
        {
            string path = IOServices.RemoveTrailingSlash(file.Path);

            bool result = Directory.Exists(path);

            Assert.False(result);
        }
    }
Esempio n. 5
0
    public static void CreateDirectory_ExistingDirectoryWithoutTrailingSlashAsPath_DoesNotThrow()
    {
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            string path = IOServices.RemoveTrailingSlash(directory.Path);

            DirectoryInfo result = Directory.CreateDirectory(path);

            Assert.Equal(path, result.FullName);
            Assert.True(Directory.Exists(result.FullName));
        }
    }
Esempio n. 6
0
    public static void CreateDirectory_FileWithoutTrailingSlashAsPath_ThrowsIOException()
    {   // VSWhidbey #104049
        using (TemporaryFile file = new TemporaryFile())
        {
            string path = IOServices.RemoveTrailingSlash(file.Path);

            Assert.Throws <IOException>(() =>
            {
                Directory.CreateDirectory(path);
            });
        }
    }
Esempio n. 7
0
        public void UnixNonSignificantTrailingWhiteSpace()
        {
            // Unix treats trailing/prename whitespace as significant and a part of the name.
            DirectoryInfo testDir    = Create(GetTestFilePath());
            var           components = IOInputs.GetWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.RemoveTrailingSlash(testDir.FullName) + component;
                DirectoryInfo result = Create(path);

                Assert.True(Directory.Exists(result.FullName));
                Assert.NotEqual(testDir.FullName, IOServices.RemoveTrailingSlash(result.FullName));
            });
        }
Esempio n. 8
0
        public void WindowsTrailingWhiteSpace()
        {
            // Windows will remove all nonsignificant whitespace in a path
            DirectoryInfo testDir    = Create(GetTestFilePath());
            var           components = IOInputs.GetWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.RemoveTrailingSlash(testDir.FullName) + component;
                DirectoryInfo result = Create(path);

                Assert.True(Directory.Exists(result.FullName));
                Assert.Equal(testDir.FullName, IOServices.RemoveTrailingSlash(result.FullName));
            });
        }
Esempio n. 9
0
        public void WindowsSimpleWhiteSpace()
        {
            // CreateSubdirectory trims all simple whitespace, returning us the parent directory
            // that called CreateSubdirectory
            var components = IOInputs.GetSimpleWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.RemoveTrailingSlash(GetTestFileName());
                DirectoryInfo result = new DirectoryInfo(TestDirectory).CreateSubdirectory(component);

                Assert.True(Directory.Exists(result.FullName));
                Assert.Equal(TestDirectory, IOServices.RemoveTrailingSlash(result.FullName));
            });
        }
Esempio n. 10
0
 public void NonExistentFile()
 {
     Assert.Throws <FileNotFoundException>(() => Set(GetTestFilePath(), FileAttributes.Normal));
     Assert.Throws <FileNotFoundException>(() => Set(IOServices.AddTrailingSlashIfNeeded(GetTestFilePath()), FileAttributes.Normal));
     Assert.Throws <FileNotFoundException>(() => Set(IOServices.RemoveTrailingSlash(GetTestFilePath()), FileAttributes.Normal));
 }
Esempio n. 11
0
        public void PathAlreadyExistsAsFile()
        {
            string path = GetTestFileName();

            File.Create(Path.Combine(TestDirectory, path)).Dispose();

            Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(path));
            Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(IOServices.AddTrailingSlashIfNeeded(path)));
            Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(IOServices.RemoveTrailingSlash(path)));
        }