diff --git a/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs b/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs index c19edf7c..49beacfa 100644 --- a/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs +++ b/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs @@ -125,15 +125,22 @@ public class AsyncParityAndCancellationTests : TestBase ); var stream = new TestStream(new MemoryStream(archiveBytes)); - await using (var archive = await ArchiveFactory.OpenAsyncArchive(stream)) + try { - await foreach (var _ in archive.EntriesAsync) + await using (var archive = await ArchiveFactory.OpenAsyncArchive(stream)) { - break; + await foreach (var _ in archive.EntriesAsync) + { + break; + } } - } - Assert.False(stream.IsDisposed); + Assert.False(stream.IsDisposed); + } + finally + { + await stream.DisposeAsync(); + } } private static List ReadArchiveEntries(string archivePath)