Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use File.OpenRead instead of File.Open in tests to allow concurrent access #895

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/SharpCompress.Test/Zip/ZipArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public void Zip_Deflate_PKWear_Multipy_Entry_Access()
{
var zipFile = Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.pkware.zip");

using var fileStream = File.Open(zipFile, FileMode.Open);
using var fileStream = File.OpenRead(zipFile);
using var archive = ArchiveFactory.Open(
fileStream,
new ReaderOptions { Password = "12345678" }
Expand Down Expand Up @@ -729,7 +729,7 @@ public void Zip_Zip64_CompressedSizeExtraOnly_Read()
public void Zip_Uncompressed_Read_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
var entries = 0;
Expand Down Expand Up @@ -758,7 +758,7 @@ public void Zip_Uncompressed_Skip_All()
"DEADBEEF",
};
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
var x = 0;
Expand All @@ -775,7 +775,7 @@ public void Zip_Uncompressed_Skip_All()
public void Zip_Forced_Ignores_UnicodePathExtra()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.UnicodePathExtra.zip");
using (var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read))
using (var stream = File.OpenRead(zipPath))
{
var archive = ArchiveFactory.Open(
stream,
Expand All @@ -791,7 +791,7 @@ public void Zip_Forced_Ignores_UnicodePathExtra()
reader.MoveToNextEntry();
Assert.Equal("궖귛궖귙귪궖귗귪궖귙_wav.frq", reader.Entry.Key);
}
using (var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read))
using (var stream = File.OpenRead(zipPath))
{
var archive = ArchiveFactory.Open(
stream,
Expand Down
6 changes: 3 additions & 3 deletions tests/SharpCompress.Test/Zip/ZipReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void Issue_685()
public void Zip_ReaderFactory_Uncompressed_Read_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
using var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{
Expand All @@ -355,7 +355,7 @@ public void Zip_ReaderFactory_Uncompressed_Read_All()
public void Zip_ReaderFactory_Uncompressed_Skip_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
using var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry()) { }
}
Expand All @@ -364,7 +364,7 @@ public void Zip_ReaderFactory_Uncompressed_Skip_All()
public void Zip_Uncompressed_64bit()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "64bitstream.zip.7z");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
reader.MoveToNextEntry();
Expand Down