refactor(kpi): K2/K6/K7 review fixups — empty-batch guard + sealed repo + uniform TryAddEnumerable + KPI-age doc fidelity + coverage
This commit is contained in:
+18
@@ -106,6 +106,24 @@ public class KpiHistoryRepositoryTests
|
||||
Assert.Equal(new[] { 1d, 2d }, series.Select(p => p.Value).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RecordSamplesAsync_EmptyBatch_IsNoOp_AndGetRawSeriesAsync_EmptyTable_ReturnsEmpty()
|
||||
{
|
||||
await using var ctx = NewContext();
|
||||
var repo = new KpiHistoryRepository(ctx);
|
||||
|
||||
// Empty batch must not throw (early-return guard, no SaveChanges round-trip).
|
||||
await repo.RecordSamplesAsync(Array.Empty<KpiSample>());
|
||||
|
||||
// With nothing written, GetRawSeriesAsync must return a non-null empty list.
|
||||
var series = await repo.GetRawSeriesAsync(
|
||||
"NotificationOutbox", "queueDepth", "Global", scopeKey: null,
|
||||
fromUtc: Base, toUtc: Base.AddMinutes(60));
|
||||
|
||||
Assert.NotNull(series);
|
||||
Assert.Empty(series);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PurgeOlderThanAsync_DeletesOnlyRowsOlderThanCutoff_AndReturnsCount()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user