Convert test data sources to typed TheoryData

Replace untyped MemberData sources with TheoryData<...>, use collection
expressions for array and list literals, drop redundant casts and null
suppressions, and give log-assertion helpers an IsEnabled setup so guarded
log calls stay verifiable.
This commit is contained in:
2026-11-29 21:42:41 +02:00
parent ada3c77778
commit 17774b40b8
31 changed files with 649 additions and 693 deletions
@@ -15,43 +15,43 @@ public class ShowerDetectionServiceTests
private DateTimeOffset Now => _timeProvider.GetUtcNow();
public static IEnumerable<object[]> IdleThresholdCases =>
[
["both thresholds met exactly", 52.0, 44.0, ShowerState.Suspected],
["rate one step under threshold", 51.98, 44.0, ShowerState.Idle],
["differential one step under threshold", 52.0, 44.02, ShowerState.Idle],
["well above both thresholds", 60.0, 52.0, ShowerState.Suspected],
["negative differential", 52.0, 60.0, ShowerState.Idle],
["zero rate with large differential", 50.0, 42.0, ShowerState.Idle],
["negative rate with large differential", 45.0, 37.0, ShowerState.Idle],
["very large humidity spike", 1000.0, 500.0, ShowerState.Suspected]
];
public static TheoryData<string, double, double, ShowerState> IdleThresholdCases => new()
{
{ "both thresholds met exactly", 52.0, 44.0, ShowerState.Suspected },
{ "rate one step under threshold", 51.98, 44.0, ShowerState.Idle },
{ "differential one step under threshold", 52.0, 44.02, ShowerState.Idle },
{ "well above both thresholds", 60.0, 52.0, ShowerState.Suspected },
{ "negative differential", 52.0, 60.0, ShowerState.Idle },
{ "zero rate with large differential", 50.0, 42.0, ShowerState.Idle },
{ "negative rate with large differential", 45.0, 37.0, ShowerState.Idle },
{ "very large humidity spike", 1000.0, 500.0, ShowerState.Suspected }
};
public static IEnumerable<object[]> ConfirmationCases =>
[
["confirmation window reached", 66.0, 49.5, 120, ShowerState.Active],
["confirmation window not yet reached", 66.0, 49.5, 119, ShowerState.Suspected],
["same instant as the spike", 66.0, 49.5, 0, ShowerState.Suspected],
["peak humidity exactly at threshold", 58.0, 49.0, 120, ShowerState.Active],
["peak humidity just below threshold", 57.5, 49.0, 120, ShowerState.Suspected],
["differential exactly at threshold", 60.0, 52.0, 120, ShowerState.Active],
["differential just below threshold", 66.0, 58.02, 120, ShowerState.Suspected],
["very large humidity at confirmation", 1000.0, 900.0, 120, ShowerState.Active]
];
public static TheoryData<string, double, double, int, ShowerState> ConfirmationCases => new()
{
{ "confirmation window reached", 66.0, 49.5, 120, ShowerState.Active },
{ "confirmation window not yet reached", 66.0, 49.5, 119, ShowerState.Suspected },
{ "same instant as the spike", 66.0, 49.5, 0, ShowerState.Suspected },
{ "peak humidity exactly at threshold", 58.0, 49.0, 120, ShowerState.Active },
{ "peak humidity just below threshold", 57.5, 49.0, 120, ShowerState.Suspected },
{ "differential exactly at threshold", 60.0, 52.0, 120, ShowerState.Active },
{ "differential just below threshold", 66.0, 58.02, 120, ShowerState.Suspected },
{ "very large humidity at confirmation", 1000.0, 900.0, 120, ShowerState.Active }
};
public static IEnumerable<object[]> RecoveryBoundaryCases =>
[
["differential well under threshold", 52.0, ShowerState.Completed],
["differential exactly at threshold", 50.0, ShowerState.Completed],
["differential just above threshold", 49.98, ShowerState.Declining]
];
public static TheoryData<string, double, ShowerState> RecoveryBoundaryCases => new()
{
{ "differential well under threshold", 52.0, ShowerState.Completed },
{ "differential exactly at threshold", 50.0, ShowerState.Completed },
{ "differential just above threshold", 49.98, ShowerState.Declining }
};
public static IEnumerable<object[]> MaxDurationCases =>
[
["one second before max duration", 3_599, ShowerState.Active],
["exactly at max duration", 3_600, ShowerState.Declining],
["one second past max duration", 3_601, ShowerState.Declining]
];
public static TheoryData<string, int, ShowerState> MaxDurationCases => new()
{
{ "one second before max duration", 3_599, ShowerState.Active },
{ "exactly at max duration", 3_600, ShowerState.Declining },
{ "one second past max duration", 3_601, ShowerState.Declining }
};
[Fact]
public void InitialState_IsIdle()