public void SuperDelete_deletes_a_directory_after_handle_is_released()
        {
            // arrange
            var directoryName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var fileName      = Path.Combine(directoryName, Guid.NewGuid().ToString());
            var delay         = TimeSpan.FromSeconds(1);

            Directory.CreateDirectory(directoryName);
            var stopwatch = Stopwatch.StartNew();
            var thread    = CreateFileWithDisappearingLock(fileName, delay);

            Assert.True(File.Exists(fileName), "Assert file exists before starting");

            // act
            SuperDeleter.SuperDelete(directoryName);

            // assert
            stopwatch.Stop();
            Assert.False(File.Exists(fileName), "Assert file no longer exists");
            Assert.False(Directory.Exists(directoryName), "Assert directory does not exist");

            // https://github.com/dotnet/runtime/issues/24432 says "no Unix or Linux file locking mechanism protects against deletion"
            //Assert.True(stopwatch.Elapsed >= delay, $"Assert elapsed time is greater than delay ({stopwatch.Elapsed.TotalMilliseconds:n1}ms < {delay.TotalMilliseconds:n1}ms)");

            // cleanup
            thread.Join();
        }
        public void SuperDelete_deletes_a_read_only_file()
        {
            // arrange
            var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            CreateReadOnlyFile(fileName);
            Assert.True(File.Exists(fileName), "Assert file exists before starting");

            // act
            SuperDeleter.SuperDelete(fileName);

            // assert
            Assert.False(File.Exists(fileName), "Assert file no longer exists");
        }
        public void SuperDelete_deletes_a_directory()
        {
            // arrange
            var directoryName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(directoryName);
            Assert.True(Directory.Exists(directoryName), "Assert directory exists before starting");

            // act
            SuperDeleter.SuperDelete(directoryName);

            // assert
            Assert.False(Directory.Exists(directoryName), "Assert directory does not exist");
        }
        public void SuperDelete_deletes_a_directory_with_read_only_file()
        {
            // arrange
            var directoryName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var fileName      = Path.Combine(directoryName, Guid.NewGuid().ToString());

            Directory.CreateDirectory(directoryName);
            CreateReadOnlyFile(fileName);
            Assert.True(File.Exists(fileName), "Assert file exists before starting");

            // act
            SuperDeleter.SuperDelete(directoryName);

            // assert
            Assert.False(File.Exists(fileName), "Assert file no longer exists");
            Assert.False(Directory.Exists(directoryName), "Assert directory does not exist");
        }