diff --git a/BatteryMonitor.Manager.Tests/BatteryMonitorTestData.cs b/BatteryMonitor.Manager.Tests/BatteryMonitorTestData.cs
index 35f90f7..3d8a85d 100644
--- a/BatteryMonitor.Manager.Tests/BatteryMonitorTestData.cs
+++ b/BatteryMonitor.Manager.Tests/BatteryMonitorTestData.cs
@@ -1,3 +1,5 @@
+#region
+
using System.Globalization;
using System.Text.Json;
using BatteryMonitor.Models;
@@ -5,6 +7,8 @@ using Moq;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
+#endregion
+
namespace BatteryMonitor.Manager.Tests;
///
@@ -20,7 +24,7 @@ internal static class BatteryMonitorTestData
/// (threshold, state, expected) rows straddling the strict level < threshold
/// boundary, including zero/negative thresholds and int min/max thresholds.
///
- public static TheoryData ThresholdBoundaryRows { get; } = new()
+ public static TheoryData ThresholdBoundaryRows { get; } = new TheoryData
{
{ 5, "4", true },
{ 5, "5", false },
@@ -59,7 +63,7 @@ internal static class BatteryMonitorTestData
"unknown",
"UNAVAILABLE",
"UNKNOWN",
- "",
+ string.Empty,
" ",
"\t",
"not_a_number",
@@ -85,8 +89,10 @@ internal static class BatteryMonitorTestData
}
/// A sensor with an arbitrary (or missing) device class.
- public static EntitySpec Sensor(string entityId, string? deviceClass, string? state,
- string? friendlyName = DefaultFriendlyName)
+ public static EntitySpec Sensor(string entityId,
+ string? deviceClass,
+ string? state,
+ string? friendlyName = DefaultFriendlyName)
{
return new EntitySpec
{
@@ -101,9 +107,15 @@ internal static class BatteryMonitorTestData
{
var attributes = new Dictionary(StringComparer.Ordinal);
- if (spec.DeviceClass is not null) attributes["device_class"] = spec.DeviceClass;
+ if (spec.DeviceClass is not null)
+ {
+ attributes["device_class"] = spec.DeviceClass;
+ }
- if (spec.FriendlyName is not null) attributes["friendly_name"] = spec.FriendlyName;
+ if (spec.FriendlyName is not null)
+ {
+ attributes["friendly_name"] = spec.FriendlyName;
+ }
return new EntityState
{
@@ -122,7 +134,10 @@ internal static class BatteryMonitorTestData
foreach (var spec in entities)
{
- if (spec.HasState) haContextMock.Setup(h => h.GetState(spec.EntityId)).Returns(CreateEntityState(spec));
+ if (spec.HasState)
+ {
+ haContextMock.Setup(h => h.GetState(spec.EntityId)).Returns(CreateEntityState(spec));
+ }
entityList.Add(new Entity(haContextMock.Object, spec.EntityId));
}
@@ -159,10 +174,10 @@ internal static class BatteryMonitorTestData
return
[
.. Enumerable.Range(0, count)
- .Select(i => Battery(
- $"sensor.generated_battery_{i:D3}",
- i.ToString(CultureInfo.InvariantCulture),
- $"Generated Battery {i:D3}"))
+ .Select(i => Battery(
+ $"sensor.generated_battery_{i:D3}",
+ i.ToString(CultureInfo.InvariantCulture),
+ $"Generated Battery {i:D3}"))
];
}
@@ -175,10 +190,10 @@ internal static class BatteryMonitorTestData
return
[
.. Enumerable.Range(0, count)
- .Select(i => CreateSensorInfo(
- $"sensor.generated_{i:D3}",
- i * 37 % 101,
- $"Generated Device {i:D3}"))
+ .Select(i => CreateSensorInfo(
+ $"sensor.generated_{i:D3}",
+ i * 37 % 101,
+ $"Generated Device {i:D3}"))
];
}
@@ -202,7 +217,7 @@ internal static class BatteryMonitorTestData
data.Add("sensor.boiler_temp_battery", false);
data.Add("sensor.aquarium_leak_sensor_battery", false);
data.Add("sensor.temperature", false);
- data.Add("", false);
+ data.Add(string.Empty, false);
data.Add(" ", false);
return data;
diff --git a/BatteryMonitor.Manager.Tests/BatteryNotificationServiceTests.cs b/BatteryMonitor.Manager.Tests/BatteryNotificationServiceTests.cs
index a27aa94..08163f7 100644
--- a/BatteryMonitor.Manager.Tests/BatteryNotificationServiceTests.cs
+++ b/BatteryMonitor.Manager.Tests/BatteryNotificationServiceTests.cs
@@ -1,3 +1,5 @@
+#region
+
using System.Text.Json;
using BatteryMonitor.Models;
using BatteryMonitorManager;
@@ -8,12 +10,14 @@ using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using static BatteryMonitor.Manager.Tests.BatteryMonitorTestData;
+#endregion
+
namespace BatteryMonitor.Manager.Tests;
public class BatteryNotificationServiceTests
{
- private readonly Mock _haContextMock = new();
- private readonly Mock> _loggerMock = new();
+ private readonly Mock _haContextMock = new Mock();
+ private readonly Mock> _loggerMock = new Mock>();
private BatteryNotificationService CreateSut()
{
@@ -23,10 +27,10 @@ public class BatteryNotificationServiceTests
private void VerifyCallService(string service, Times times)
{
_haContextMock.Verify(h => h.CallService(
- BatteryMonitorConsts.PersistentNotificationDomain,
- service,
- It.IsAny(),
- It.IsAny