-
-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
Description
Thanks for the amazing work on the Testably libraries.
I'm getting a lock error on a file that was zipped
System.IO.IOException
The process cannot access the file 'C:\ToBeZipped\file.txt' because it is being used by another process.
at Testably.Abstractions.Testing.Storage.InMemoryContainer.RequestAccess(FileAccess access, FileShare share, Boolean deleteAccess, Boolean ignoreFileShare, Boolean ignoreMetadataErrors, Nullable`1 hResult)
at Testably.Abstractions.Testing.Storage.InMemoryStorage.DeleteContainer(IStorageLocation location, FileSystemTypes expectedType, Boolean recursive)
at Testably.Abstractions.Testing.Storage.InMemoryStorage.DeleteContainer(IStorageLocation location, FileSystemTypes expectedType, Boolean recursive)
at Testably.Abstractions.Testing.FileSystem.DirectoryInfoMock.Delete(Boolean recursive)
at Testably.Abstractions.Testing.FileSystem.DirectoryMock.Delete(String path, Boolean recursive)You can repro with this test:
using System.IO.Abstractions;
using Testably.Abstractions;
using Testably.Abstractions.Testing;
namespace TestProject1;
public class UnitTest1
{
[Fact]
public void Test1()
{
IFileSystem fileSystem = new MockFileSystem();
string directory = @"C:\ToBeZipped";
string file = fileSystem.Path.Combine(directory, "file.txt");
string archive = @"c:\zippedDirectory.zip";
fileSystem.Directory.CreateDirectory(directory);
fileSystem.File.WriteAllText(file, "Some content");
fileSystem.ZipFile().CreateFromDirectory(directory, archive);
fileSystem.Directory.Delete(directory, true);
}
}Problem doesn't occur with a RealFileSystem.
Thanks for looking into this.