1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using Evergreen.Health.Application.Health.Devices.Environment;
|
||||
using Evergreen.Health.Application.Health.Integrations.HomeAssistant;
|
||||
using Evergreen.Health.Application.Health.Services;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace Admin.NET.Test.Health;
|
||||
|
||||
public sealed class ClimateAdviceBindingTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("", "15", "heat", true)]
|
||||
[InlineData("climate.room", "15", "heat", false)]
|
||||
[InlineData("climate.room", "28", "cool", false)]
|
||||
[InlineData("", "24", "off", false)]
|
||||
public void AdviceUsesBindingNotPowerStateToReportPendingIntegration(
|
||||
string climate, string temperature, string mode, bool pending)
|
||||
{
|
||||
var options = Options.Create(new HomeAssistantOptions
|
||||
{
|
||||
Entities = new() { Climate = climate, Temperature = "sensor.room" }
|
||||
});
|
||||
var gateway = new FakeHaGateway();
|
||||
var states = new Dictionary<string, HomeAssistantState>
|
||||
{
|
||||
["sensor.room"] = new()
|
||||
{
|
||||
EntityId = "sensor.room", State = temperature,
|
||||
LastReported = DateTimeOffset.UtcNow,
|
||||
Attributes = JsonSerializer.SerializeToElement(new { unit_of_measurement = "°C" })
|
||||
}
|
||||
};
|
||||
var service = new MattressComfortService(gateway,
|
||||
new IndoorEnvironmentReader(options, TimeProvider.System), options);
|
||||
var output = service.Get(null, states);
|
||||
Assert.Equal(mode, output.ClimateAdvice.Mode);
|
||||
Assert.Equal(pending, output.ClimateAdvice.PendingIntegration);
|
||||
Assert.Null(output.ClimateAdvice.TargetTemperatureCelsius);
|
||||
Assert.Empty(gateway.Calls);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user