Add manual MQTT recreation and NordPool price fetch buttons
This commit is contained in:
@@ -31,13 +31,14 @@ public class NordPoolEntityServiceTests
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Should().HaveCount(6);
|
||||
result.Should().HaveCount(7);
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_last_update_time");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_current_price");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_today_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_tomorrow_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_today_tomorrow_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_cheapest_intervals");
|
||||
result.Should().Contain(e => e.EntityId == "button.nordpool_fetch_prices");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -74,7 +75,7 @@ public class NordPoolEntityServiceTests
|
||||
var result = _sut.GetInitEntitiesList("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
result.Should().OnlyContain(e => e.Domain == "sensor");
|
||||
result.Should().OnlyContain(e => e.Domain == "sensor" || e.Domain == "button");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -102,7 +103,7 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.CreateEntitiesAsync("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(6));
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -126,7 +127,7 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.CreateEntitiesAsync("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(6));
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(7));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -150,6 +151,7 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_tomorrow_prices"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_today_tomorrow_prices"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_cheapest_intervals"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("button.nordpool_fetch_prices"), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -255,6 +257,7 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_tomorrow_prices", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_today_tomorrow_prices", "unknown"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_cheapest_intervals", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("button.nordpool_fetch_prices", "unknown"), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -276,6 +279,7 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_tomorrow_prices", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_today_tomorrow_prices", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_cheapest_intervals", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("button.nordpool_fetch_prices", It.IsAny<object>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -299,7 +303,7 @@ public class NordPoolEntityServiceTests
|
||||
[Fact]
|
||||
public async Task ResetEntitiesAsync_ShouldCallSetStateAndAttributesCorrectly()
|
||||
{
|
||||
// Arrange - 6 entities get state and attributes
|
||||
// Arrange - 7 entities get state and attributes
|
||||
_entityManagerMock.Setup(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(Task.CompletedTask);
|
||||
_entityManagerMock.Setup(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()))
|
||||
@@ -309,8 +313,8 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.ResetEntitiesAsync();
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(6));
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()), Times.Exactly(6));
|
||||
_entityManagerMock.Verify(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(7));
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()), Times.Exactly(7));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -67,6 +67,7 @@ public class NordPoolInitTests
|
||||
|
||||
return new NordPoolInit(
|
||||
_entities,
|
||||
_haContextMock.Object,
|
||||
_loggerMock.Object,
|
||||
_priceServiceMock.Object,
|
||||
_entityServiceMock.Object,
|
||||
|
||||
Reference in New Issue
Block a user