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:
@@ -1,3 +1,5 @@
|
||||
#region
|
||||
|
||||
using LightMonitor.Models;
|
||||
using LightMonitorManager;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -6,6 +8,8 @@ using Moq;
|
||||
using NetDaemon.HassModel;
|
||||
using NetDaemon.HassModel.Entities;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace LightMonitor.Manager.Tests;
|
||||
|
||||
public class LightControlServiceTests
|
||||
@@ -15,20 +19,20 @@ public class LightControlServiceTests
|
||||
|
||||
private readonly LightMonitorOptions _defaultOptions = LightMonitorTestData.CreateOptions();
|
||||
|
||||
private readonly Mock<IHaContext> _haContextMock = new();
|
||||
private readonly Mock<IHaContext> _haContextMock = new Mock<IHaContext>();
|
||||
|
||||
private LightControlService CreateService(LightMonitorOptions? options = null)
|
||||
{
|
||||
return new LightControlService(
|
||||
_haContextMock.Object,
|
||||
Mock.Of<ILogger<LightControlService>>(),
|
||||
Options.Create(options ?? _defaultOptions));
|
||||
_haContextMock.Object,
|
||||
Mock.Of<ILogger<LightControlService>>(),
|
||||
Options.Create(options ?? _defaultOptions));
|
||||
}
|
||||
|
||||
private void SetupState(string entityId, string? state)
|
||||
{
|
||||
_haContextMock.Setup(x => x.GetState(entityId))
|
||||
.Returns(LightMonitorTestData.CreateOptionalState(state));
|
||||
.Returns(LightMonitorTestData.CreateOptionalState(state));
|
||||
}
|
||||
|
||||
private void VerifyTurnOn(string entityId, bool shouldTurnOn)
|
||||
@@ -36,17 +40,17 @@ public class LightControlServiceTests
|
||||
if (!shouldTurnOn)
|
||||
{
|
||||
_haContextMock.Verify(x => x.CallService(
|
||||
It.IsAny<string>(), It.IsAny<string>(),
|
||||
It.IsAny<ServiceTarget>(), It.IsAny<object?>()),
|
||||
Times.Never);
|
||||
It.IsAny<string>(), It.IsAny<string>(),
|
||||
It.IsAny<ServiceTarget>(), It.IsAny<object?>()),
|
||||
Times.Never);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_haContextMock.Verify(x => x.CallService("light", "turn_on",
|
||||
It.Is<ServiceTarget>(target => target.EntityIds != null && target.EntityIds.Contains(entityId)),
|
||||
It.IsAny<object?>()),
|
||||
Times.Once);
|
||||
It.Is<ServiceTarget>(target => target.EntityIds != null && target.EntityIds.Contains(entityId)),
|
||||
It.IsAny<object?>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
Reference in New Issue
Block a user