Files
HomeAssistant/NordPool.Manager.Tests/NordPoolInitTests.cs
T
Marius 53eb53539a Add input_boolean for water heater preparation logic
Refreshed logic to allow users to toggle hot water preparation. Introduced new `input_boolean.boiler_prepare_hot_water` and updated config, services, and tests to ensure water readiness only when required.
2026-03-16 11:42:49 +02:00

75 lines
2.3 KiB
C#

using System.Reactive.Concurrency;
using FluentAssertions;
using HomeAssistantGenerated;
using Microsoft.Extensions.Logging;
using Moq;
using NetDaemon.HassModel;
using NordPoolManager;
using NordPoolManager.Interface;
namespace NordPool.Manager.Tests;
public class NordPoolInitTests
{
private readonly Mock<ILogger<NordPoolInit>> _loggerMock;
private readonly Mock<INordPoolPriceService> _priceServiceMock;
private readonly Mock<INordPoolEntityService> _entityServiceMock;
private readonly Mock<IScheduler> _schedulerMock;
private readonly Mock<ICheapestIntervalsFinder> _cheapestIntervalsFinderMock;
private readonly Mock<IBoilerControlService> _boilerControlServiceMock;
private readonly Mock<IHaContext> _haContextMock;
private readonly Entities _entities;
public NordPoolInitTests()
{
_loggerMock = new Mock<ILogger<NordPoolInit>>();
_priceServiceMock = new Mock<INordPoolPriceService>();
_entityServiceMock = new Mock<INordPoolEntityService>();
_schedulerMock = new Mock<IScheduler>();
_schedulerMock.Setup(s => s.Now).Returns(DateTimeOffset.UtcNow);
_cheapestIntervalsFinderMock = new Mock<ICheapestIntervalsFinder>();
_boilerControlServiceMock = new Mock<IBoilerControlService>();
_haContextMock = new Mock<IHaContext>();
_entities = new Entities(_haContextMock.Object);
}
private NordPoolInit CreateSut()
{
return new NordPoolInit(
_entities,
_haContextMock.Object,
_loggerMock.Object,
_priceServiceMock.Object,
_entityServiceMock.Object,
_schedulerMock.Object,
_cheapestIntervalsFinderMock.Object,
_boilerControlServiceMock.Object
);
}
[Fact]
public void Constructor_ShouldInitializeCorrectly()
{
// Arrange & Act
var sut = CreateSut();
// Assert
sut.Should().NotBeNull();
}
[Fact]
public async Task CleanupEntitiesAsync_ShouldDelegateToEntityService()
{
// Arrange
var sut = CreateSut();
_entityServiceMock.Setup(es => es.CleanupEntitiesAsync())
.Returns(Task.CompletedTask);
// Act
await sut.CleanupEntitiesAsync();
// Assert
_entityServiceMock.Verify(es => es.CleanupEntitiesAsync(), Times.Once);
}
}