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
@@ -20,42 +20,42 @@ public class ExhaustFanControlServiceTests
private DateTimeOffset Now => _timeProvider.GetUtcNow();
public static IEnumerable<object[]> ShowerProgressFanStateCases =>
[
["active while fan is off", ShowerState.Active, "off", true],
["active while fan is on", ShowerState.Active, "on", false],
["active while fan reports uppercase on", ShowerState.Active, "ON", false],
["active while fan is unavailable", ShowerState.Active, "unavailable", true],
["active while fan state is unknown", ShowerState.Active, "unknown", true],
["active while fan state is empty", ShowerState.Active, "", true],
["active while fan state is missing", ShowerState.Active, null!, true],
["suspected while fan is off", ShowerState.Suspected, "off", true],
["suspected while fan is on", ShowerState.Suspected, "on", false],
["idle does not touch the fan", ShowerState.Idle, "off", false],
["declining does not turn the fan on", ShowerState.Declining, "off", false],
["completed does not turn the fan on", ShowerState.Completed, "off", false]
];
public static TheoryData<string, ShowerState, string?, bool> ShowerProgressFanStateCases => new()
{
{ "active while fan is off", ShowerState.Active, "off", true },
{ "active while fan is on", ShowerState.Active, "on", false },
{ "active while fan reports uppercase on", ShowerState.Active, "ON", false },
{ "active while fan is unavailable", ShowerState.Active, "unavailable", true },
{ "active while fan state is unknown", ShowerState.Active, "unknown", true },
{ "active while fan state is empty", ShowerState.Active, "", true },
{ "active while fan state is missing", ShowerState.Active, null, true },
{ "suspected while fan is off", ShowerState.Suspected, "off", true },
{ "suspected while fan is on", ShowerState.Suspected, "on", false },
{ "idle does not touch the fan", ShowerState.Idle, "off", false },
{ "declining does not turn the fan on", ShowerState.Declining, "off", false },
{ "completed does not turn the fan on", ShowerState.Completed, "off", false }
};
public static IEnumerable<object[]> FanRunAfterCases =>
[
["well before run-after duration", 10, 60, false],
["one second before run-after duration", 10, 599, false],
["exactly at run-after duration", 10, 600, true],
["one second after run-after duration", 10, 601, true],
["well after run-after duration", 10, 660, true],
["zero-minute run-after turns off immediately", 0, 0, true],
["long run-after keeps fan running", 30, 300, false]
];
public static TheoryData<string, int, int, bool> FanRunAfterCases => new()
{
{ "well before run-after duration", 10, 60, false },
{ "one second before run-after duration", 10, 599, false },
{ "exactly at run-after duration", 10, 600, true },
{ "one second after run-after duration", 10, 601, true },
{ "well after run-after duration", 10, 660, true },
{ "zero-minute run-after turns off immediately", 0, 0, true },
{ "long run-after keeps fan running", 30, 300, false }
};
public static IEnumerable<object[]> ResetCases =>
[
["fan on after we turned it on", true, "on", true],
["fan reports uppercase on", true, "ON", true],
["fan already off again", true, "off", false],
["fan unavailable", true, "unavailable", false],
["fan state missing", true, null!, false],
["we never turned the fan on", false, "on", false]
];
public static TheoryData<string, bool, string?, bool> ResetCases => new()
{
{ "fan on after we turned it on", true, "on", true },
{ "fan reports uppercase on", true, "ON", true },
{ "fan already off again", true, "off", false },
{ "fan unavailable", true, "unavailable", false },
{ "fan state missing", true, null, false },
{ "we never turned the fan on", false, "on", false }
};
[Theory]
[MemberData(nameof(ShowerProgressFanStateCases))]