Files
HomeAssistant/BoilerMonitor.Manager.Tests/BoilerMonitorConfigTests.cs
T

134 lines
3.7 KiB
C#

using FluentAssertions;
using BoilerMonitorManager.Models;
namespace BoilerMonitor.Manager.Tests;
public class BoilerMonitorConfigTests
{
[Fact]
public void IsFullyConfigured_WhenAllFieldsSet_ShouldReturnTrue()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeTrue();
}
[Fact]
public void IsFullyConfigured_WhenPowerEntityMissing_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = null,
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenSwitchEntityMissing_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = null,
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenPollIntervalMissing_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = null,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenThresholdMissing_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = null
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenPowerEntityIsWhitespace_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = " ",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenPollIntervalIsZero_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 0,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenThresholdIsZero_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = 30,
HeatingPowerThresholdWatts = 0.0
};
config.IsFullyConfigured.Should().BeFalse();
}
[Fact]
public void IsFullyConfigured_WhenPollIntervalIsNegative_ShouldReturnFalse()
{
var config = new BoilerMonitorConfig
{
BoilerPowerEntityId = "sensor.power",
BoilerSwitchEntityId = "switch.boiler",
PollIntervalSeconds = -1,
HeatingPowerThresholdWatts = 5.0
};
config.IsFullyConfigured.Should().BeFalse();
}
}