Convert test data sources to typed TheoryData
Replace untyped MemberData sources with TheoryData<...>, use collection expressions for array and list literals, drop redundant casts and null suppressions, and give log-assertion helpers an IsEnabled setup so guarded log calls stay verifiable.
This commit is contained in:
@@ -12,23 +12,17 @@ namespace BatteryMonitor.Manager.Tests;
|
||||
|
||||
public class BatterySensorDiscoveryServiceTests
|
||||
{
|
||||
private readonly Mock<IHaContext> _haContextMock;
|
||||
private readonly Mock<ILogger<BatterySensorDiscoveryService>> _loggerMock;
|
||||
|
||||
public BatterySensorDiscoveryServiceTests()
|
||||
{
|
||||
_haContextMock = new Mock<IHaContext>();
|
||||
_loggerMock = new Mock<ILogger<BatterySensorDiscoveryService>>();
|
||||
}
|
||||
private readonly Mock<IHaContext> _haContextMock = new();
|
||||
private readonly Mock<ILogger<BatterySensorDiscoveryService>> _loggerMock = new();
|
||||
|
||||
private BatterySensorDiscoveryService CreateSut()
|
||||
{
|
||||
return new BatterySensorDiscoveryService(_haContextMock.Object, _loggerMock.Object);
|
||||
}
|
||||
|
||||
private IReadOnlyList<Entity> SetupEntities(params EntitySpec[] entities)
|
||||
private void SetupEntities(params EntitySpec[] entities)
|
||||
{
|
||||
return ConfigureHaContext(_haContextMock, entities);
|
||||
ConfigureHaContext(_haContextMock, entities);
|
||||
}
|
||||
|
||||
#region Discovery
|
||||
@@ -139,11 +133,13 @@ public class BatterySensorDiscoveryServiceTests
|
||||
|
||||
result.Should().HaveCount(expectedIncluded ? 1 : 0);
|
||||
|
||||
if (expectedIncluded)
|
||||
if (!expectedIncluded)
|
||||
{
|
||||
result[0].EntityId.Should().Be("sensor.boundary_battery");
|
||||
result[0].BatteryLevel.Should().Be(double.Parse(state, CultureInfo.InvariantCulture));
|
||||
return;
|
||||
}
|
||||
|
||||
result[0].EntityId.Should().Be("sensor.boundary_battery");
|
||||
result[0].BatteryLevel.Should().Be(double.Parse(state, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user