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
@@ -8,37 +8,37 @@ public class BoilerMonitorConfigTests
private const string PowerEntityId = BoilerMonitorTestData.PowerEntityId;
private const string SwitchEntityId = BoilerMonitorTestData.SwitchEntityId;
public static IEnumerable<object?[]> ConfigurationCases =>
[
["fully configured", PowerEntityId, SwitchEntityId, 30, 5.0, true],
["minimum valid poll interval and threshold", PowerEntityId, SwitchEntityId, 5, 1.0, true],
["poll interval of one second", PowerEntityId, SwitchEntityId, 1, 5.0, true],
["maximum poll interval", PowerEntityId, SwitchEntityId, int.MaxValue, 5.0, true],
["smallest positive threshold", PowerEntityId, SwitchEntityId, 30, double.Epsilon, true],
["maximum threshold", PowerEntityId, SwitchEntityId, 30, double.MaxValue, true],
["infinite threshold", PowerEntityId, SwitchEntityId, 30, double.PositiveInfinity, true],
public static TheoryData<string, string?, string?, int?, double?, bool> ConfigurationCases => new()
{
{ "fully configured", PowerEntityId, SwitchEntityId, 30, 5.0, true },
{ "minimum valid poll interval and threshold", PowerEntityId, SwitchEntityId, 5, 1.0, true },
{ "poll interval of one second", PowerEntityId, SwitchEntityId, 1, 5.0, true },
{ "maximum poll interval", PowerEntityId, SwitchEntityId, int.MaxValue, 5.0, true },
{ "smallest positive threshold", PowerEntityId, SwitchEntityId, 30, double.Epsilon, true },
{ "maximum threshold", PowerEntityId, SwitchEntityId, 30, double.MaxValue, true },
{ "infinite threshold", PowerEntityId, SwitchEntityId, 30, double.PositiveInfinity, true },
["power entity id null", (string?)null, SwitchEntityId, 30, 5.0, false],
["power entity id empty", "", SwitchEntityId, 30, 5.0, false],
["power entity id whitespace", " ", SwitchEntityId, 30, 5.0, false],
["power entity id tabs and newlines", "\t\n", SwitchEntityId, 30, 5.0, false],
["switch entity id null", PowerEntityId, (string?)null, 30, 5.0, false],
["switch entity id empty", PowerEntityId, "", 30, 5.0, false],
["switch entity id whitespace", PowerEntityId, " ", 30, 5.0, false],
["both entity ids null", (string?)null, (string?)null, 30, 5.0, false],
{ "power entity id null", null, SwitchEntityId, 30, 5.0, false },
{ "power entity id empty", "", SwitchEntityId, 30, 5.0, false },
{ "power entity id whitespace", " ", SwitchEntityId, 30, 5.0, false },
{ "power entity id tabs and newlines", "\t\n", SwitchEntityId, 30, 5.0, false },
{ "switch entity id null", PowerEntityId, null, 30, 5.0, false },
{ "switch entity id empty", PowerEntityId, "", 30, 5.0, false },
{ "switch entity id whitespace", PowerEntityId, " ", 30, 5.0, false },
{ "both entity ids null", null, null, 30, 5.0, false },
["poll interval null", PowerEntityId, SwitchEntityId, (int?)null, 5.0, false],
["poll interval zero", PowerEntityId, SwitchEntityId, 0, 5.0, false],
["poll interval negative", PowerEntityId, SwitchEntityId, -1, 5.0, false],
["poll interval minimum value", PowerEntityId, SwitchEntityId, int.MinValue, 5.0, false],
{ "poll interval null", PowerEntityId, SwitchEntityId, null, 5.0, false },
{ "poll interval zero", PowerEntityId, SwitchEntityId, 0, 5.0, false },
{ "poll interval negative", PowerEntityId, SwitchEntityId, -1, 5.0, false },
{ "poll interval minimum value", PowerEntityId, SwitchEntityId, int.MinValue, 5.0, false },
["threshold null", PowerEntityId, SwitchEntityId, 30, (double?)null, false],
["threshold zero", PowerEntityId, SwitchEntityId, 30, 0.0, false],
["threshold negative", PowerEntityId, SwitchEntityId, 30, -1.0, false],
["threshold minimum value", PowerEntityId, SwitchEntityId, 30, double.MinValue, false],
["threshold NaN", PowerEntityId, SwitchEntityId, 30, double.NaN, false],
["threshold negative infinity", PowerEntityId, SwitchEntityId, 30, double.NegativeInfinity, false]
];
{ "threshold null", PowerEntityId, SwitchEntityId, 30, null, false },
{ "threshold zero", PowerEntityId, SwitchEntityId, 30, 0.0, false },
{ "threshold negative", PowerEntityId, SwitchEntityId, 30, -1.0, false },
{ "threshold minimum value", PowerEntityId, SwitchEntityId, 30, double.MinValue, false },
{ "threshold NaN", PowerEntityId, SwitchEntityId, 30, double.NaN, false },
{ "threshold negative infinity", PowerEntityId, SwitchEntityId, 30, double.NegativeInfinity, false }
};
[Theory]
[MemberData(nameof(ConfigurationCases))]