Clear the residual Qodana findings

- Drop the leftover unused using, parameter and date-time attribute reader
- Merge the remaining enum guard into its pattern
- Make the NordPool price DTO init-only
- Replace the four non-serializable theory matrices with single tests that
  iterate the same rows, so xUnit can still report them
- Replace Array.Empty with collection expressions and drop unused locals,
  redundant default arguments and duplicated tuple names
- Throw from the unreachable shower default instead of an empty section
- Cover the configurable PowerMonitor option overrides in a test so the
  init setters have a caller
This commit is contained in:
2026-11-29 21:49:21 +02:00
parent 41ac93733e
commit cf8c9434c8
15 changed files with 173 additions and 206 deletions
@@ -21,11 +21,11 @@ public class OtherPowerCalculationServiceTests
public static TheoryData<string, double, double[], double, string> CalculationCases => new()
{
{ "two devices", 341.97, [8.55, 36.93], 296.49, "ok" },
{ "no devices", 341.97, Array.Empty<double>(), 341.97, "ok" },
{ "no devices", 341.97, [], 341.97, "ok" },
{ "devices exceed total", 341.97, [200.0, 180.0], 0.0, "device_sum_exceeds_total" },
{ "devices equal total", 100.0, [60.0, 40.0], 0.0, "ok" },
{ "zero power, no devices", 0.0, Array.Empty<double>(), 0.0, "ok" },
{ "negative total, no devices", -120.0, Array.Empty<double>(), 0.0, "device_sum_exceeds_total" },
{ "zero power, no devices", 0.0, [], 0.0, "ok" },
{ "negative total, no devices", -120.0, [], 0.0, "device_sum_exceeds_total" },
{ "negative device reading", 100.0, [150.0, -40.0], 0.0, "device_sum_exceeds_total" },
{ "very large values", 1_000_000.0, [250_000.0, 250_000.0], 500_000.0, "ok" },
{ "very small values", 0.5, [0.25], 0.25, "ok" }
@@ -43,7 +43,7 @@ public class OtherPowerCalculationServiceTests
// Arrange
var sut = CreateSut(smoothingWindowSize: 1);
var devices = deviceWatts
.Select((watts, index) => (entityId: $"sensor.device{index}_power", watts: watts))
.Select((watts, index) => (entityId: $"sensor.device{index}_power", watts))
.ToDictionary(entry => entry.entityId, entry => entry.watts);
// Act