예제 #1
0
        public void EmptyDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var directory  = fileSystem.StageDirectory(@"\directory");

            fileSystem.StageDirectory(@"\directory\child1");
            fileSystem.StageDirectory(@"\directory\child2");
            fileSystem.StageDirectory(@"\directory\child3");
            fileSystem.StageFile(@"\directory\file1.dat");
            fileSystem.StageFile(@"\directory\file2.dat");
            fileSystem.StageFile(@"\directory\file3.dat");
            fileSystem.StageFile(@"\directory\child2\fileA.dat");
            fileSystem.StageFile(@"\directory\child2\fileB.dat");
            fileSystem.StageFile(@"\directory\child2\fileC.dat");

            // Execute
            directory.Empty();

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"\directory"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child1"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child2"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child3"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file2.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file3.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileA.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileB.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileC.dat"));
        }
예제 #2
0
        public void DirectoryExistsWithNull()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            // Execute
            var results = fileSystem.DirectoryExists(a_path: null);
        }
예제 #3
0
        public void DirectoryExistsWithBadPath()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path       = @"X:\This is bad a directory path?";

            // Execute
            fileSystem.DirectoryExists(path);
        }
예제 #4
0
        public void DeleteDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory(@"x:\directory1");
            fileSystem.StageDirectory(@"X:\DIRECTORY2\CHILD");
            fileSystem.StageFile(@"x:\directory2\file.rgb", new TestFileInstance());

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory2");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory1"));
            Assert.IsFalse(fileSystem.DirectoryExists((@"x:\directory2")));
            Assert.IsFalse(fileSystem.DirectoryExists(@"x:\directory2\child"));
            Assert.IsFalse(fileSystem.FileExists(@"x:\directory2\file.rgb"));
        }
예제 #5
0
        public void DeleteNotExistingDirectory()
        {
            // Setup
            var root       = Path.GetPathRoot(Environment.SystemDirectory);
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory($@"{root}directory1");
            fileSystem.StageDirectory($@"{root}directory2\child");
            fileSystem.StageFile($@"{root}directory2\file.rgb", new TestFileInstance());

            // Execute
            fileSystem.DeleteDirectory(@"\directory3");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory1"));
            Assert.IsTrue(fileSystem.DirectoryExists(($@"{root}directory2")));
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory2\child"));
            Assert.IsTrue(fileSystem.FileExists($@"{root}directory2\file.rgb"));
        }
예제 #6
0
        public void CopyTo()
        {
            // Setup
            var source = new TestDirectory(_fileSystem, @"\Root\Directory\Sub1");
            var dest   = new TestDirectory(_fileSystem, @"\Root\Directory\SubA");

            // Execute
            DirectoryHelpers.CopyTo(source, dest);

            // Assert
            Assert.IsTrue(_fileSystem.DirectoryExists(@"\Root\Directory\SubA"));
            Assert.IsTrue(_fileSystem.DirectoryExists(@"\Root\Directory\SubA\Sub2"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\Sub2\File1.dat"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\Sub2\File2.dat"));
            Assert.IsTrue(_fileSystem.DirectoryExists(@"\Root\Directory\SubA\Sub3"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\Sub3\File1.dat"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\Sub3\File2.dat"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\File1.dat"));
            Assert.IsTrue(_fileSystem.FileExists(@"\Root\Directory\SubA\File2.dat"));
        }
예제 #7
0
        public void CreateDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path       = @"X:\This is a directory path\";

            // Execute
            fileSystem.StageDirectory(path);

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(path));
        }
예제 #8
0
        public void CreateDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path = @"X:\This is a directory path\";

            // Execute
            fileSystem.StageDirectory(path);

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(path));
        }
예제 #9
0
        public void DirectoryExistsWithMissingEndSlash()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory(@"X:\This is a directory path\");

            // Execute
            var results = fileSystem.DirectoryExists(@"X:\This is a directory path");

            // Assert
            Assert.IsTrue(results);
        }
예제 #10
0
        public void DirectoryExistsOnChildDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory(@"X:\Parent\Child");

            // Execute
            var results = fileSystem.DirectoryExists(@"X:\Parent");

            // Assert
            Assert.IsTrue(results);
        }
예제 #11
0
        public void DirectoryExistsWithNotExistingDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path       = @"X:\This is a directory path\";

            // Execute
            path = path.ToLower(); // Ignores case.
            var results = fileSystem.DirectoryExists(path.ToLower());

            // Assert
            Assert.IsFalse(results);
        }
예제 #12
0
        public void DeleteDirectoryWithPartialName()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory(@"x:\directory\this is a directory");
            fileSystem.StageDirectory(@"x:\directory\this is");

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory\this is");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory\this is a directory"));
        }
예제 #13
0
        public void DirectoryExists()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path       = @"X:\This is a directory path\";

            fileSystem.StageDirectory(path);

            // Execute
            path = path.ToLower(); // Ignores case.
            var results = fileSystem.DirectoryExists(path.ToLower());

            // Assert
            Assert.IsTrue(results);
        }
예제 #14
0
        public void CopyIn()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var directory  = fileSystem.StageDirectory(@"D:\directory");
            var other      = fileSystem.StageDirectory(@"D:\other");

            // Executea
            var result = DirectoryHelpers.CopyIn(directory, other);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Exists);
            Assert.AreEqual(@"D:\directory\other", result.Path);
            Assert.IsTrue(fileSystem.DirectoryExists(@"D:\directory\other"));
            Assert.IsInstanceOfType(result, typeof(TestDirectory));
            Assert.AreSame(fileSystem, (result as TestDirectory)?.FileSystem);
        }
예제 #15
0
        public void CopyIn()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var directory = fileSystem.StageDirectory(@"D:\directory");
            var other = fileSystem.StageDirectory(@"D:\other");

            // Executea
            var result = DirectoryHelpers.CopyIn(directory, other);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Exists);
            Assert.AreEqual(@"D:\directory\other", result.Path);
            Assert.IsTrue(fileSystem.DirectoryExists(@"D:\directory\other"));
            Assert.IsInstanceOfType(result, typeof(TestDirectory));
            Assert.AreSame(fileSystem, (result as TestDirectory)?.FileSystem);
        }
예제 #16
0
        public void DirectoryExistsWithNotExistingDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path = @"X:\This is a directory path\";

            // Execute
            path = path.ToLower(); // Ignores case.
            var results = fileSystem.DirectoryExists(path.ToLower());

            // Assert
            Assert.IsFalse(results);
        }
예제 #17
0
        public void DeleteDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory(@"x:\directory1");
            fileSystem.StageDirectory(@"X:\DIRECTORY2\CHILD");
            fileSystem.StageFile(@"x:\directory2\file.rgb", new TestFileInstance());

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory2");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory1"));
            Assert.IsFalse(fileSystem.DirectoryExists((@"x:\directory2")));
            Assert.IsFalse(fileSystem.DirectoryExists(@"x:\directory2\child"));
            Assert.IsFalse(fileSystem.FileExists(@"x:\directory2\file.rgb"));
        }
예제 #18
0
        public void EmptyDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var directory = fileSystem.StageDirectory(@"\directory");
            fileSystem.StageDirectory(@"\directory\child1");
            fileSystem.StageDirectory(@"\directory\child2");
            fileSystem.StageDirectory(@"\directory\child3");
            fileSystem.StageFile(@"\directory\file1.dat");
            fileSystem.StageFile(@"\directory\file2.dat");
            fileSystem.StageFile(@"\directory\file3.dat");
            fileSystem.StageFile(@"\directory\child2\fileA.dat");
            fileSystem.StageFile(@"\directory\child2\fileB.dat");
            fileSystem.StageFile(@"\directory\child2\fileC.dat");

            // Execute
            directory.Empty();

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"\directory"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child1"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child2"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child3"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file2.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file3.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileA.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileB.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileC.dat"));
        }
예제 #19
0
        public void DeleteNotExistingDirectory()
        {
            // Setup
            var root = Path.GetPathRoot(Environment.SystemDirectory);
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory($@"{root}directory1");
            fileSystem.StageDirectory($@"{root}directory2\child");
            fileSystem.StageFile($@"{root}directory2\file.rgb", new TestFileInstance());

            // Execute
            fileSystem.DeleteDirectory(@"\directory3");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory1"));
            Assert.IsTrue(fileSystem.DirectoryExists(($@"{root}directory2")));
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory2\child"));
            Assert.IsTrue(fileSystem.FileExists($@"{root}directory2\file.rgb"));
        }
예제 #20
0
        public void DeleteDirectoryWithPartialName()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory(@"x:\directory\this is a directory");
            fileSystem.StageDirectory(@"x:\directory\this is");

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory\this is");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory\this is a directory"));
        }
예제 #21
0
        public void DirectoryExists()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path = @"X:\This is a directory path\";
            fileSystem.StageDirectory(path);

            // Execute
            path = path.ToLower(); // Ignores case.
            var results = fileSystem.DirectoryExists(path.ToLower());

            // Assert
            Assert.IsTrue(results);
        }
예제 #22
0
        public void DirectoryExistsOnChildDirectory()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory(@"X:\Parent\Child");

            // Execute
            var results = fileSystem.DirectoryExists(@"X:\Parent");

            // Assert
            Assert.IsTrue(results);
        }
예제 #23
0
        public void DirectoryExistsWithBadPath()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var path = @"X:\This is bad a directory path?";

            // Execute
            fileSystem.DirectoryExists(path);
        }
예제 #24
0
        public void DirectoryExistsWithMissingEndSlash()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory(@"X:\This is a directory path\");

            // Execute
            var results = fileSystem.DirectoryExists(@"X:\This is a directory path");

            // Assert
            Assert.IsTrue(results);
        }
예제 #25
0
        public void DirectoryExistsWithNull()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            // Execute
            var results = fileSystem.DirectoryExists(a_path: null);
        }