Fix culture-sensitive parsing, log swallowing and closure capture

- DateTimeTypeConverter parses with the invariant culture instead of the
  ambient one (NordPool timestamps arrive as ISO-8601)
- Shower last-shower-time state is formatted with the invariant culture
- PresenceServiceTests no longer captures the loop variable in a Moq setup
- CheapestIntervalsFinderTests compare prices with a tolerance instead of
  floating-point equality
- MqttRecreateApp logs the unit_of_measurement read failure instead of
  silently swallowing every exception
- LightMonitorOptions moves to LightMonitor.Models so the namespace matches
  the project and file location
This commit is contained in:
2026-11-29 21:31:45 +02:00
parent b5e114be14
commit ada3c77778
15 changed files with 25 additions and 24 deletions
@@ -5,7 +5,6 @@ using Moq;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using LightMonitorManager;
using LightMonitorManager.Models;
namespace LightMonitor.Manager.Tests;
@@ -8,7 +8,6 @@ using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using LightMonitorManager;
using LightMonitorManager.Interface;
using LightMonitorManager.Models;
namespace LightMonitor.Manager.Tests;
@@ -1,5 +1,4 @@
using LightMonitor.Models;
using LightMonitorManager.Models;
using NetDaemon.HassModel.Entities;
namespace LightMonitor.Manager.Tests;
@@ -6,7 +6,6 @@ using Moq;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using LightMonitorManager;
using LightMonitorManager.Models;
namespace LightMonitor.Manager.Tests;
@@ -24,12 +23,15 @@ public class PresenceServiceTests
Options.Create(options ?? _defaultOptions));
}
private void SetupStates(IReadOnlyList<string?> personStates)
private void SetupStates(string?[] personStates)
{
for (var index = 0; index < personStates.Count; index++)
for (var index = 0; index < personStates.Length; index++)
{
_haContextMock.Setup(x => x.GetState(LightMonitorTestData.PersonEntityIds[index]))
.Returns(LightMonitorTestData.CreateOptionalState(personStates[index]));
var entityId = LightMonitorTestData.PersonEntityIds[index];
var state = LightMonitorTestData.CreateOptionalState(personStates[index]);
_haContextMock.Setup(x => x.GetState(entityId))
.Returns(state);
}
}