This commit is contained in:
Marius
2026-03-08 19:10:16 +02:00
commit 861c344832
74 changed files with 34756 additions and 0 deletions
@@ -0,0 +1,73 @@
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,
_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);
}
}