Init
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user