Apply code formatting cleanup across the monitor projects

- Wrap using directives in `#region` blocks across the Battery, Boiler and NordPool sources and tests
- Expand single-statement guards and loops into braced blocks
- Realign wrapped method arguments, chained calls and continuations
- Replace target-typed `new()` with explicit generic construction and empty string literals with `string.Empty`
- Flatten the boiler config expression and reindent the remaining touched files
This commit is contained in:
2026-12-01 12:33:31 +02:00
parent 77458383d1
commit f919d6b25b
115 changed files with 3115 additions and 1959 deletions
@@ -1,3 +1,5 @@
#region
using System.Text.Json;
using LeakMonitor.Models;
using LeakMonitorManager.Models;
@@ -5,6 +7,8 @@ using Moq;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
#endregion
namespace LeakMonitor.Manager.Tests;
/// <summary>
@@ -20,12 +24,12 @@ internal static class LeakMonitorTestData
public static readonly string[] DefaultSensorIds = [AquariumSensorId, BoilerSensorId];
private static readonly DateTimeOffset DefaultStart = new(2026, 1, 15, 12, 0, 0, TimeSpan.Zero);
private static readonly DateTimeOffset DefaultStart = new DateTimeOffset(2026, 1, 15, 12, 0, 0, TimeSpan.Zero);
/// <summary>
/// Every casing of the "water detected" state, across both configured sensors.
/// </summary>
public static TheoryData<string, string?> WaterDetectedCases { get; } = new()
public static TheoryData<string, string?> WaterDetectedCases { get; } = new TheoryData<string, string?>
{
{ AquariumSensorId, LeakMonitorConsts.WaterDetectedState },
{ AquariumSensorId, "ON" },
@@ -37,7 +41,7 @@ internal static class LeakMonitorTestData
/// <summary>
/// Every casing of the "water cleared" state, across both configured sensors.
/// </summary>
public static TheoryData<string, string?> WaterClearedCases { get; } = new()
public static TheoryData<string, string?> WaterClearedCases { get; } = new TheoryData<string, string?>
{
{ AquariumSensorId, LeakMonitorConsts.WaterClearedState },
{ AquariumSensorId, "OFF" },
@@ -83,7 +87,7 @@ internal static class LeakMonitorTestData
/// (sensor id, expected notification id) rows for the id sanitising rules:
/// dots become underscores, other characters and blanks are preserved.
/// </summary>
public static TheoryData<string, string> NotificationIdCases { get; } = new()
public static TheoryData<string, string> NotificationIdCases { get; } = new TheoryData<string, string>
{
{ AquariumSensorId, "leak_monitor_binary_sensor_aquarium_leak_sensor" },
{ BoilerSensorId, "leak_monitor_binary_sensor_boiler_moisture" },
@@ -100,7 +104,7 @@ internal static class LeakMonitorTestData
/// rows straddling the strict <c>elapsed &lt; cooldown</c> boundary, plus zero, negative
/// and int-max cooldowns.
/// </summary>
public static TheoryData<int, int, int> CooldownBoundaryCases { get; } = new()
public static TheoryData<int, int, int> CooldownBoundaryCases { get; } = new TheoryData<int, int, int>
{
{ 5, 0, 1 },
{ 5, 299, 1 },
@@ -172,7 +176,7 @@ internal static class LeakMonitorTestData
string? newState)
{
return new StateChange(new Entity(haContext, entityId), CreateOptionalState(oldState),
CreateOptionalState(newState));
CreateOptionalState(newState));
}
public static IReadOnlyList<StateChange> CreateStateChangeSequence(
@@ -183,7 +187,7 @@ internal static class LeakMonitorTestData
return
[
.. transitions.Select(transition =>
CreateStateChange(haContext, entityId, transition.OldState, transition.NewState))
CreateStateChange(haContext, entityId, transition.OldState, transition.NewState))
];
}
@@ -196,13 +200,13 @@ internal static class LeakMonitorTestData
var calls = new List<ServiceCall>();
haContextMock
.Setup(h => h.CallService(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<ServiceTarget?>(),
It.IsAny<object?>()))
.Callback<string, string, ServiceTarget?, object?>((domain, service, target, data) =>
calls.Add(new ServiceCall(domain, service, target, data)));
.Setup(h => h.CallService(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<ServiceTarget?>(),
It.IsAny<object?>()))
.Callback<string, string, ServiceTarget?, object?>((domain, service, target, data) =>
calls.Add(new ServiceCall(domain, service, target, data)));
return calls;
}
@@ -258,7 +262,10 @@ internal static class LeakMonitorTestData
public void Publish(T value)
{
foreach (var observer in _observers.ToArray()) observer.OnNext(value);
foreach (var observer in _observers.ToArray())
{
observer.OnNext(value);
}
}
private sealed class Subscription(List<IObserver<T>> observers, IObserver<T> observer) : IDisposable