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:
2026-11-29 21:42:41 +02:00
parent ada3c77778
commit 17774b40b8
31 changed files with 649 additions and 693 deletions
@@ -85,7 +85,7 @@ public class LeakNotificationServiceTests
var calls = LeakMonitorTestData.CaptureServiceCalls(_haContextMock);
var sut = CreateSut();
const string sensorId = LeakMonitorTestData.AquariumSensorId;
var expectedMessage = $"Water detected by {sensorId}! Check immediately.";
const string expectedMessage = $"Water detected by {sensorId}! Check immediately.";
sut.SendLeakAlert(sensorId);
@@ -136,8 +136,11 @@ public class LeakNotificationServiceTests
sut.SendLeakAlert(sensorId);
var persistentCall = calls.Single(c =>
c.Domain == LeakMonitorConsts.PersistentNotificationDomain &&
c.Service == LeakMonitorConsts.PersistentNotificationCreateService);
c is
{
Domain: LeakMonitorConsts.PersistentNotificationDomain,
Service: LeakMonitorConsts.PersistentNotificationCreateService
});
LeakMonitorTestData.SerializePayload(persistentCall.Data)
.GetProperty("notification_id")
@@ -345,7 +348,7 @@ public class LeakNotificationServiceTests
public void BuildNotificationId_WithNullSensorId_ShouldThrow()
{
// Production has no null guard; the string.Replace call fails before any prefix is built.
Action act = () => LeakNotificationService.BuildNotificationId(null!);
var act = () => LeakNotificationService.BuildNotificationId(null!);
act.Should().Throw<NullReferenceException>();
}