docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
This commit is contained in:
@@ -86,15 +86,24 @@ public class KpiMetricAggregationTests
|
||||
(KpiSources.SiteHealth, "localDbReplicationConnected"),
|
||||
};
|
||||
|
||||
/// <summary>Supplies every emitted source and metric pair as theory data.</summary>
|
||||
/// <returns>The theory data rows of source and metric names.</returns>
|
||||
public static IEnumerable<object[]> AllEmittedCases() =>
|
||||
AllEmittedMetrics.Select(m => new object[] { m.Source, m.Metric });
|
||||
|
||||
/// <summary>Supplies the rate metric source and metric pairs as theory data.</summary>
|
||||
/// <returns>The theory data rows of source and metric names.</returns>
|
||||
public static IEnumerable<object[]> RateCases() =>
|
||||
RateMetrics.Select(m => new object[] { m.Source, m.Metric });
|
||||
|
||||
/// <summary>Supplies the gauge-sampled source and metric pairs as theory data.</summary>
|
||||
/// <returns>The theory data rows of source and metric names.</returns>
|
||||
public static IEnumerable<object[]> GaugeCases() =>
|
||||
GaugeSampling.Select(m => new object[] { m.Source, m.Metric });
|
||||
|
||||
/// <summary>Verifies that every emitted metric resolves to a defined aggregation.</summary>
|
||||
/// <param name="source">The KPI source name.</param>
|
||||
/// <param name="metric">The metric name.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(AllEmittedCases))]
|
||||
public void Resolve_EveryEmittedMetric_ReturnsDefinedAggregation(string source, string metric)
|
||||
@@ -106,6 +115,9 @@ public class KpiMetricAggregationTests
|
||||
$"({source}, {metric}) resolved to an undefined aggregation: {result}");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that rate metrics are classified as rate.</summary>
|
||||
/// <param name="source">The KPI source name.</param>
|
||||
/// <param name="metric">The metric name.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(RateCases))]
|
||||
public void Resolve_RateMetrics_ClassifiedAsRate(string source, string metric)
|
||||
@@ -113,6 +125,9 @@ public class KpiMetricAggregationTests
|
||||
Assert.Equal(KpiRollupAggregation.Rate, KpiMetricAggregationCatalog.Resolve(source, metric));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that gauge-sampled metrics are classified as gauge.</summary>
|
||||
/// <param name="source">The KPI source name.</param>
|
||||
/// <param name="metric">The metric name.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(GaugeCases))]
|
||||
public void Resolve_GaugeSampling_ClassifiedAsGauge(string source, string metric)
|
||||
@@ -120,6 +135,7 @@ public class KpiMetricAggregationTests
|
||||
Assert.Equal(KpiRollupAggregation.Gauge, KpiMetricAggregationCatalog.Resolve(source, metric));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that last-hour audit metrics resolve as gauges rather than rates.</summary>
|
||||
[Fact]
|
||||
public void Resolve_LastHourAuditMetrics_AreGaugeNotRate()
|
||||
{
|
||||
@@ -133,6 +149,9 @@ public class KpiMetricAggregationTests
|
||||
KpiMetricAggregationCatalog.Resolve(KpiSources.AuditLog, "errorEventsLastHour"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unknown metric defaults to a gauge.</summary>
|
||||
/// <param name="source">The KPI source name.</param>
|
||||
/// <param name="metric">The metric name.</param>
|
||||
[Theory]
|
||||
[InlineData(KpiSources.NotificationOutbox, "someBrandNewMetricAddedLater")]
|
||||
[InlineData("AnEntirelyNewSource", "anyMetric")]
|
||||
@@ -144,6 +163,7 @@ public class KpiMetricAggregationTests
|
||||
Assert.Equal(KpiRollupAggregation.Gauge, KpiMetricAggregationCatalog.Resolve(source, metric));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the same metric name under a different source is keyed on the source and metric pair.</summary>
|
||||
[Fact]
|
||||
public void Resolve_SameMetricNameDifferentSource_KeysOnSourcePair()
|
||||
{
|
||||
@@ -157,8 +177,9 @@ public class KpiMetricAggregationTests
|
||||
KpiMetricAggregationCatalog.Resolve(KpiSources.SiteCallAudit, "deliveredLastInterval"));
|
||||
}
|
||||
|
||||
// ---- Task 8: catalog metric literals promoted to shared KpiMetrics constants (R4) ----
|
||||
// ---- Catalog metric literals promoted to shared KpiMetrics constants (R4) ----
|
||||
|
||||
/// <summary>Verifies that the promoted metric constants lock the historical persisted values.</summary>
|
||||
[Fact]
|
||||
public void PromotedMetricConstants_LockHistoricalPersistedValues()
|
||||
{
|
||||
@@ -168,6 +189,9 @@ public class KpiMetricAggregationTests
|
||||
Assert.Equal("eventLogWriteFailures", KpiMetrics.SiteHealth.EventLogWriteFailures);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the promoted rate pairs still classify as rate.</summary>
|
||||
/// <param name="source">The KPI source name.</param>
|
||||
/// <param name="metric">The metric name.</param>
|
||||
[Theory]
|
||||
[InlineData(KpiSources.SiteCallAudit, KpiMetrics.SiteCallAudit.DeliveredLastInterval)]
|
||||
[InlineData(KpiSources.SiteHealth, KpiMetrics.SiteHealth.AlarmEvalErrors)]
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Kpi;
|
||||
|
||||
public class KpiSampleTests
|
||||
{
|
||||
/// <summary>Verifies that a KpiSample constructed with its required members round-trips the values.</summary>
|
||||
[Fact]
|
||||
public void KpiSample_ConstructedWithRequiredMembers_RoundTripsValues()
|
||||
{
|
||||
@@ -31,6 +32,7 @@ public class KpiSampleTests
|
||||
Assert.Equal(DateTimeKind.Utc, sample.CapturedAtUtc.Kind);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a scoped sample carries its scope key.</summary>
|
||||
[Fact]
|
||||
public void KpiSample_ScopedSample_CarriesScopeKey()
|
||||
{
|
||||
@@ -49,6 +51,7 @@ public class KpiSampleTests
|
||||
Assert.Equal(12.5, sample.Value);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that each KPI scope and source constant equals its own name.</summary>
|
||||
[Fact]
|
||||
public void KpiScopesAndSources_ConstantValues_EqualTheirNames()
|
||||
{
|
||||
@@ -62,6 +65,7 @@ public class KpiSampleTests
|
||||
Assert.Equal("Node", KpiScopes.Node);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that KpiSeriesPoint is a value record struct with component-wise equality.</summary>
|
||||
[Fact]
|
||||
public void KpiSeriesPoint_IsValueRecordStruct_WithComponentEquality()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ public class KpiSeriesBucketerTests
|
||||
// Guard / invalid-argument contracts
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a maximum point count below two throws an ArgumentOutOfRangeException.</summary>
|
||||
[Fact]
|
||||
public void Bucket_MaxPointsLessThan2_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
@@ -25,6 +26,7 @@ public class KpiSeriesBucketerTests
|
||||
KpiSeriesBucketer.Bucket(raw, T(0), T(60), maxPoints: 1));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a maximum point count of zero throws an ArgumentOutOfRangeException.</summary>
|
||||
[Fact]
|
||||
public void Bucket_MaxPointsZero_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
@@ -34,6 +36,7 @@ public class KpiSeriesBucketerTests
|
||||
KpiSeriesBucketer.Bucket(raw, T(0), T(60), maxPoints: 0));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a window whose end equals its start throws an ArgumentOutOfRangeException.</summary>
|
||||
[Fact]
|
||||
public void Bucket_ToUtcEqualFromUtc_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
@@ -43,6 +46,7 @@ public class KpiSeriesBucketerTests
|
||||
KpiSeriesBucketer.Bucket(raw, T(30), T(30), maxPoints: 5));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a window that ends before it starts throws an ArgumentOutOfRangeException.</summary>
|
||||
[Fact]
|
||||
public void Bucket_ToUtcBeforeFromUtc_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
@@ -56,6 +60,7 @@ public class KpiSeriesBucketerTests
|
||||
// Empty / null raw series
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a null raw series returns an empty list.</summary>
|
||||
[Fact]
|
||||
public void Bucket_NullRaw_ReturnsEmptyList()
|
||||
{
|
||||
@@ -64,6 +69,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an empty raw series returns an empty list.</summary>
|
||||
[Fact]
|
||||
public void Bucket_EmptyRaw_ReturnsEmptyList()
|
||||
{
|
||||
@@ -77,6 +83,7 @@ public class KpiSeriesBucketerTests
|
||||
// raw.Count <= maxPoints → returned unchanged (same reference)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a raw series with exactly the maximum number of points is returned as the same reference.</summary>
|
||||
[Fact]
|
||||
public void Bucket_RawCountEqualsMaxPoints_ReturnsSameReference()
|
||||
{
|
||||
@@ -92,6 +99,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Same(raw, result);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a raw series with fewer points than the maximum is returned as the same reference.</summary>
|
||||
[Fact]
|
||||
public void Bucket_RawCountLessThanMaxPoints_ReturnsSameReference()
|
||||
{
|
||||
@@ -106,6 +114,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Same(raw, result);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a single-point series is returned as the same reference.</summary>
|
||||
[Fact]
|
||||
public void Bucket_SinglePoint_ReturnsSameReference()
|
||||
{
|
||||
@@ -120,6 +129,7 @@ public class KpiSeriesBucketerTests
|
||||
// Downsampling: correct bucket count and last-value selection
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a series with more points than the maximum is reduced to the maximum number of buckets.</summary>
|
||||
[Fact]
|
||||
public void Bucket_MorePointsThanMaxPoints_ReducesToMaxPointsBuckets()
|
||||
{
|
||||
@@ -140,6 +150,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(30.0, result[2].Value);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that when several points fall in the same bucket the last value wins.</summary>
|
||||
[Fact]
|
||||
public void Bucket_MultiplePointsInSameBucket_LastValueWins()
|
||||
{
|
||||
@@ -160,6 +171,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(5.0, result[1].Value); // only point in bucket 1
|
||||
}
|
||||
|
||||
/// <summary>Verifies that each output point carries the bucket start rather than the raw point timestamp.</summary>
|
||||
[Fact]
|
||||
public void Bucket_BucketStartUtc_IsSetToBucketStartNotRawPointTimestamp()
|
||||
{
|
||||
@@ -187,10 +199,11 @@ public class KpiSeriesBucketerTests
|
||||
// Unsorted input: last-in-iteration wins within a bucket (NOT largest timestamp)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that for unsorted input the last point in iteration order is selected, not the point with the largest timestamp.</summary>
|
||||
[Fact]
|
||||
public void Bucket_UnsortedInput_SelectsLastInIterationNotLargestTimestamp()
|
||||
{
|
||||
// KpiHistory-006 regression: pins the documented contract that for unsorted input the
|
||||
// Regression: pins the documented contract that for unsorted input the
|
||||
// bucketer selects the LAST point in iteration order within a bucket — it does NOT pick
|
||||
// the largest-timestamp point. Both points below fall in bucket 0 ([0, 30)); the later
|
||||
// one in iteration order, T(5)=value 1.0, arrives second, so it overwrites T(20)=value
|
||||
@@ -216,10 +229,11 @@ public class KpiSeriesBucketerTests
|
||||
// Short series (raw.Count <= maxPoints): returned unchanged → raw capture timestamps
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a short series keeps its raw capture timestamps instead of bucket boundaries.</summary>
|
||||
[Fact]
|
||||
public void Bucket_ShortSeries_ReturnsRawCaptureTimestampsNotBucketBoundaries()
|
||||
{
|
||||
// KpiHistory-005/003 regression: the short-series early-return path returns the input
|
||||
// Regression: the short-series early-return path returns the input
|
||||
// unchanged, so each output point's BucketStartUtc is the RAW capture timestamp — NOT a
|
||||
// bucket-boundary timestamp (which is what the downsample path emits, asserted by
|
||||
// Bucket_BucketStartUtc_IsSetToBucketStartNotRawPointTimestamp). This pins the
|
||||
@@ -243,6 +257,7 @@ public class KpiSeriesBucketerTests
|
||||
// Right-edge: point exactly at toUtc lands in the last bucket
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a point exactly at the window end lands in the last bucket.</summary>
|
||||
[Fact]
|
||||
public void Bucket_PointAtToUtc_LandsInLastBucket()
|
||||
{
|
||||
@@ -264,6 +279,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(7.0, result[1].Value);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that in a three-bucket window a point exactly at the window end lands in the last bucket.</summary>
|
||||
[Fact]
|
||||
public void Bucket_ThreeBucketWindow_PointAtToUtc_LandsInLastBucket()
|
||||
{
|
||||
@@ -291,6 +307,7 @@ public class KpiSeriesBucketerTests
|
||||
// Empty buckets omitted — no gap-filling
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that empty buckets caused by a gap in the raw data are omitted.</summary>
|
||||
[Fact]
|
||||
public void Bucket_GapInRaw_EmptyBucketsOmitted()
|
||||
{
|
||||
@@ -329,6 +346,7 @@ public class KpiSeriesBucketerTests
|
||||
// Points outside [fromUtc, toUtc] are ignored
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that points outside the window are ignored.</summary>
|
||||
[Fact]
|
||||
public void Bucket_PointsOutsideWindow_AreIgnored()
|
||||
{
|
||||
@@ -353,6 +371,7 @@ public class KpiSeriesBucketerTests
|
||||
// Two-point minimum — maxPoints == 2 works correctly
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a maximum of exactly two points produces at most two buckets.</summary>
|
||||
[Fact]
|
||||
public void Bucket_MaxPointsExactly2_ProducesAtMostTwoBuckets()
|
||||
{
|
||||
@@ -374,6 +393,7 @@ public class KpiSeriesBucketerTests
|
||||
// Per-metric reduction: Rate series sum per bucket (arch-review 04 round 2, R3)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// <summary>Verifies that a rate series sums the values in each bucket instead of taking the last value.</summary>
|
||||
[Fact]
|
||||
public void Bucket_RateSeries_SumsPerBucket_InsteadOfLastValue()
|
||||
{
|
||||
@@ -397,6 +417,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(30.0, result[1].Value);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a short rate series still sums clustered points.</summary>
|
||||
[Fact]
|
||||
public void Bucket_RateSeries_ShortSeries_StillSumsClusteredPoints()
|
||||
{
|
||||
@@ -418,6 +439,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(10.0, result[1].Value); // T(30) alone
|
||||
}
|
||||
|
||||
/// <summary>Verifies that bucketing a rate series preserves the series total.</summary>
|
||||
[Fact]
|
||||
public void Bucket_RateSeries_PreservesSeriesTotal()
|
||||
{
|
||||
@@ -436,6 +458,7 @@ public class KpiSeriesBucketerTests
|
||||
Assert.Equal(inWindowTotal, result.Sum(p => p.Value));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the default aggregation is gauge and its behavior is unchanged.</summary>
|
||||
[Fact]
|
||||
public void Bucket_DefaultAggregation_IsGauge_AndBehaviorUnchanged()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user