mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-07-08 18:16:30 +00:00
Fix flaky progress test by using synchronous IProgress implementation
This commit is contained in:
committed by
GitHub
parent
afea217934
commit
ae8d983b72
@@ -286,9 +286,9 @@
|
||||
"net10.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[10.0.0, )",
|
||||
"resolved": "10.0.0",
|
||||
"contentHash": "kICGrGYEzCNI3wPzfEXcwNHgTvlvVn9yJDhSdRK+oZQy4jvYH529u7O0xf5ocQKzOMjfS07+3z9PKRIjrFMJDA=="
|
||||
"requested": "[10.0.8, )",
|
||||
"resolved": "10.0.8",
|
||||
"contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
@@ -388,9 +388,9 @@
|
||||
"net8.0": {
|
||||
"Microsoft.NET.ILLink.Tasks": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.22, )",
|
||||
"resolved": "8.0.22",
|
||||
"contentHash": "MhcMithKEiyyNkD2ZfbDZPmcOdi0GheGfg8saEIIEfD/fol3iHmcV8TsZkD4ZYz5gdUuoX4YtlVySUU7Sxl9SQ=="
|
||||
"requested": "[8.0.27, )",
|
||||
"resolved": "8.0.27",
|
||||
"contentHash": "rQi9TxifHRnXP7lVRZH05DxD2/XGbJp12q0ozcbrlBlBnyyzssFTH/2vLhtKWUp2CT1qVscTrcYTFiwTyKPKRg=="
|
||||
},
|
||||
"Microsoft.NETFramework.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -147,7 +147,7 @@ public class SevenZipArchiveAsyncTests : ArchiveTests
|
||||
public async Task SevenZipArchive_Solid_WriteToDirectoryAsync_WithProgress()
|
||||
{
|
||||
var progressReports = new System.Collections.Generic.List<ProgressReport>();
|
||||
var progress = new Progress<ProgressReport>(report => progressReports.Add(report));
|
||||
var progress = new SynchronousProgress<ProgressReport>(report => progressReports.Add(report));
|
||||
var testArchive = Path.Combine(TEST_ARCHIVES_PATH, "7Zip.solid.7z");
|
||||
#if NETFRAMEWORK
|
||||
using var stream = File.OpenRead(testArchive);
|
||||
@@ -158,7 +158,6 @@ public class SevenZipArchiveAsyncTests : ArchiveTests
|
||||
|
||||
await archive.WriteToDirectoryAsync(SCRATCH_FILES_PATH, progress: progress);
|
||||
|
||||
await Task.Delay(1000);
|
||||
VerifyFiles();
|
||||
Assert.True(progressReports.Count > 0, "Progress reports should be generated");
|
||||
}
|
||||
@@ -358,4 +357,13 @@ public class SevenZipArchiveAsyncTests : ArchiveTests
|
||||
// The critical check: within a single folder, the stream should NEVER be recreated
|
||||
Assert.Equal(0, streamRecreationsWithinFolder); // Folder stream should remain the same for all entries in the same folder
|
||||
}
|
||||
|
||||
private sealed class SynchronousProgress<T> : IProgress<T>
|
||||
{
|
||||
private readonly Action<T> _handler;
|
||||
|
||||
public SynchronousProgress(Action<T> handler) => _handler = handler;
|
||||
|
||||
public void Report(T value) => _handler(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user