コード例 #1
0
        public void ComponentDeleteDirectoryAction_Deletes_Directory_Including_SubDirectories_And_Files()
        {
            // Create parent directory
            string directoryName = "ComponentDeleteDirectoryAction_Parent";

            _pathOriginal = Path.Combine(_assemblyFolder, directoryName);

            Directory.CreateDirectory(_pathOriginal);
            Assert.IsTrue(Directory.Exists(_pathOriginal));

            // Create child directory
            string subdirectoryName = "ComponentDeleteDirectoryAction_Child";
            string pathSubdirectory = Path.Combine(_pathOriginal, subdirectoryName);

            Directory.CreateDirectory(pathSubdirectory);
            Assert.IsTrue(Directory.Exists(pathSubdirectory));

            // Create file within child directory
            string fileName = "ComponentDeleteDirectoryAction_File.txt";
            string pathFile = Path.Combine(pathSubdirectory, fileName);
            var    myFile   = File.Create(pathFile);

            myFile.Close();

            Assert.IsTrue(File.Exists(pathFile));

            // Remove parent directory
            FolderLibrary.ComponentDeleteDirectoryAction(_pathOriginal, removeOtherFilesDirectoriesInPath: true);

            Assert.IsFalse(Directory.Exists(_pathOriginal));
        }
コード例 #2
0
        public void ComponentDeleteDirectoryAction_Events_Log_From_Exception()
        {
            // Create parent directory
            string directoryName = "ComponentDeleteDirectoryAction_Events_Log_From_Exception_Base";

            _pathOriginal = Path.Combine(_assemblyFolder, directoryName);

            Directory.CreateDirectory(_pathOriginal);
            Assert.IsTrue(Directory.Exists(_pathOriginal));

            // Create child directory
            string subdirectoryName = "ComponentDeleteDirectoryAction_Events_Log_From_Exception_Sub";
            string pathSubdirectory = Path.Combine(_pathOriginal, subdirectoryName);

            Directory.CreateDirectory(pathSubdirectory);
            Assert.IsTrue(Directory.Exists(pathSubdirectory));

            // Set up event listener
            var wasCalled = false;

            FolderLibrary.Log += (e) => wasCalled = true;

            // Remove parent directory
            FolderLibrary.ComponentDeleteDirectoryAction(_pathOriginal, removeOtherFilesDirectoriesInPath: false);

            Assert.IsTrue(wasCalled);
        }
コード例 #3
0
        public void ComponentDeleteDirectoryAction_Deletes_Directory()
        {
            // Create directory
            string directoryName = "ComponentDeleteDirectoryAction_Deletes_Directory_Base";

            _pathOriginal = Path.Combine(_assemblyFolder, directoryName);

            Directory.CreateDirectory(_pathOriginal);
            Assert.IsTrue(Directory.Exists(_pathOriginal));

            // Remove Directory
            FolderLibrary.ComponentDeleteDirectoryAction(_pathOriginal);

            Assert.IsFalse(Directory.Exists(_pathOriginal));
        }