Beispiel #1
0
 public void NonExistentValidPath_ReturnsFalse()
 {
     Assert.All((IOInputs.GetValidPathComponentNames()), (path) =>
     {
         Assert.False(Exists(path), path);
     });
 }
Beispiel #2
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));
     });
 }
Beispiel #3
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));
     });
 }
Beispiel #4
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);
        }
    }
Beispiel #5
0
        public void ValidPathWithoutTrailingSlash()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            var components = IOInputs.GetValidPathComponentNames();

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

                Assert.Equal(path, result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            });
        }
Beispiel #6
0
        public void ValidExtendedPathWithTrailingSlash()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            var components = IOInputs.GetValidPathComponentNames();

            Assert.All(components, (component) =>
            {
                string path          = IOInputs.ExtendedPrefix + IOServices.AddTrailingSlashIfNeeded(Path.Combine(testDir.FullName, component));
                DirectoryInfo result = Create(path);

                Assert.Equal(path, result.FullName);
                Assert.True(result.Exists);
            });
        }
Beispiel #7
0
        public void ValidPathWithTrailingSlash()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            var components = IOInputs.GetValidPathComponentNames();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.AddTrailingSlashIfNeeded(component);
                DirectoryInfo result = new DirectoryInfo(testDir.FullName).CreateSubdirectory(path);

                Assert.Equal(Path.Combine(testDir.FullName, path), result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            });
        }
Beispiel #8
0
    public static void Exists_ExistentValidPathAsPath_ReturnsTrue()
    {
        var components = IOInputs.GetValidPathComponentNames();

        foreach (string component in components)
        {
            using (TemporaryDirectory directory = new TemporaryDirectory())
            {
                string path = Path.Combine(directory.Path, component);
                Directory.CreateDirectory(path);

                bool result = Directory.Exists(path);

                Assert.True(result, path);
            }
        }
    }
Beispiel #9
0
    public static void CreateDirectory_ValidPathWithoutTrailingSlashAsPath_CanBeCreated()
    {
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            var components = IOInputs.GetValidPathComponentNames();

            foreach (var component in components)
            {
                string path = directory.Path + Path.DirectorySeparatorChar + component;

                DirectoryInfo result = Directory.CreateDirectory(path);

                Assert.Equal(path, result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            }
        }
    }
Beispiel #10
0
    public static void CreateDirectory_ValidPathWithTrailingSlash_CanBeCreated()
    {
        using (TemporaryDirectory directory = new TemporaryDirectory())
        {
            var components = IOInputs.GetValidPathComponentNames();

            foreach (var component in components)
            {
                string path = IOServices.AddTrailingSlashIfNeeded(Path.Combine(directory.Path, component));

                DirectoryInfo result = Directory.CreateDirectory(path);

                Assert.Equal(path, result.FullName);
                Assert.True(Directory.Exists(result.FullName));
            }
        }
    }