Skip to content
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public API only — no breaking change.

- Built against `Wolfgang.Etl.Abstractions` 0.17.0 → **0.18.0**.
- The doubles' `CreateProgressReport()` now surfaces the base's `StartedAt`/`Elapsed` timing
(Abstractions 0.14.0) in the `Report`, so `ItemsPerSecond` is computed for reported progress.
(Abstractions 0.14.0) in the `Report`, so `ItemsPerSecond` is computed for reported progress;
the extractor doubles also set `TotalItemCount` from a materialized collection source so
`PercentComplete`/`EstimatedRemaining` compute.

## [0.10.1] - 2026-07-24

Expand Down
10 changes: 9 additions & 1 deletion src/Wolfgang.Etl.TestKit/FaultyExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,15 @@ protected override void Dispose(bool disposing)

/// <inheritdoc/>
protected override Report CreateProgressReport() =>
new(CurrentItemCount) { StartedAt = StartedAt, Elapsed = Elapsed };
new(CurrentItemCount)
{
StartedAt = StartedAt,
Elapsed = Elapsed,

// When the source is a materialized collection its size is a cheap, known
// total, so PercentComplete / EstimatedRemaining can be computed.
TotalItemCount = (_items as ICollection<T>)?.Count,
};



Expand Down
11 changes: 10 additions & 1 deletion src/Wolfgang.Etl.TestKit/TestExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,16 @@ protected override void Dispose(bool disposing)

/// <inheritdoc/>
protected override Report CreateProgressReport() =>
new(CurrentItemCount) { StartedAt = StartedAt, Elapsed = Elapsed };
new(CurrentItemCount)
{
StartedAt = StartedAt,
Elapsed = Elapsed,

// When the source is a materialized collection its size is a cheap, known
// total, so PercentComplete / EstimatedRemaining can be computed. An
// enumerator- or factory-backed source has no known total (stays null).
TotalItemCount = (_enumerable as ICollection<T>)?.Count,
};



Expand Down
27 changes: 27 additions & 0 deletions tests/Wolfgang.Etl.TestKit.Tests.Unit/DoubleReportTimingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ public async Task CreateProgressReport_after_a_run_computes_a_non_negative_throu
Assert.True(report.ItemsPerSecond >= 0);
}

[Fact]
public async Task CreateProgressReport_for_a_collection_source_surfaces_TotalItemCount()
{
var sut = new ExposedTestExtractor<int>(new List<int> { 1, 2, 3, 4, 5 });

await sut.ExtractAsync().ToListAsync();
var report = sut.GetProgressReport();

Assert.Equal(5, report.TotalItemCount);
Assert.Equal(100d, report.PercentComplete!.Value);
}

[Fact]
public void CreateProgressReport_for_an_enumerator_source_has_no_TotalItemCount()
{
var sut = new ExposedTestExtractor<int>(Enumerable.Range(1, 3).GetEnumerator());

var report = sut.GetProgressReport();

Assert.Null(report.TotalItemCount);
}

private sealed class ExposedTestExtractor<T> : TestExtractor<T>
where T : notnull
{
Expand All @@ -58,6 +80,11 @@ public ExposedTestExtractor(IEnumerable<T> items)
{
}

public ExposedTestExtractor(IEnumerator<T> enumerator)
: base(enumerator)
{
}

public Report GetProgressReport() => CreateProgressReport();
}
}
Loading