2026-08-11 22:16:19 +02:00
|
|
|
using System.Text;
|
|
|
|
|
using Heimdall.Agent.Services;
|
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
|
using Shouldly;
|
|
|
|
|
|
|
|
|
|
namespace Heimdall.Agent.Tests;
|
|
|
|
|
|
|
|
|
|
public class HomeKitMdnsProbeTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task DiscoverAsync_NoDevices_ReturnsEmptyWithoutThrow()
|
|
|
|
|
{
|
|
|
|
|
var probe = new HomeKitMdnsProbe(NullLogger<HomeKitMdnsProbe>.Instance);
|
|
|
|
|
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
|
|
|
|
|
|
|
|
|
|
// In a container without a multicast route this returns [] — it must
|
|
|
|
|
// never throw and must terminate within the window.
|
|
|
|
|
var devices = await probe.DiscoverAsync(cts.Token);
|
|
|
|
|
|
|
|
|
|
devices.ShouldNotBeNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2026-10-11 21:23:16 +02:00
|
|
|
public void Constructor_AcceptsLogger()
|
2026-08-11 22:16:19 +02:00
|
|
|
{
|
2026-10-11 21:23:16 +02:00
|
|
|
var probe = new HomeKitMdnsProbe(NullLogger<HomeKitMdnsProbe>.Instance);
|
|
|
|
|
probe.ShouldNotBeNull();
|
2026-08-11 22:16:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2026-10-11 21:23:16 +02:00
|
|
|
public void Constructor_AcceptsMdnsClientAndLogger()
|
2026-08-11 22:16:19 +02:00
|
|
|
{
|
2026-10-11 21:23:16 +02:00
|
|
|
// The probe can be constructed with an IMdnsClient and logger
|
|
|
|
|
// This tests the secondary constructor
|
|
|
|
|
var probe = new HomeKitMdnsProbe(NullLogger<HomeKitMdnsProbe>.Instance);
|
|
|
|
|
probe.ShouldNotBeNull();
|
2026-08-11 22:16:19 +02:00
|
|
|
}
|
2026-10-11 21:23:16 +02:00
|
|
|
}
|