This document provides a comprehensive guide to testing the Arkane.Zeroconf library. The test suite includes unit tests, integration tests, platform-specific tests, end-to-end tests, and performance tests.
The main test project targeting .NET 10.0 with the following test categories:
ServiceBrowserTests.cs- Tests for ServiceBrowser wrapperRegisterServiceTests.cs- Tests for RegisterService wrapperTxtRecordTests.cs- Tests for TxtRecord wrapperZeroconfSupportTests.cs- Tests for capability checks (CanBrowse,CanPublish)
Purpose: Verify that public facade classes correctly delegate to provider implementations, expose provider capability checks, and handle parameter validation.
ProviderFactoryTests.cs- Tests for provider discovery and selectionWindowsMdnsProviderTests.cs- Tests for Windows fallback provider capability and lookup-only publish behaviorSystemdResolvedProviderTests.cs- Tests for Linux systemd-resolved fallback provider capability and publish behavior
Purpose: Verify provider discovery and runtime fallback behavior.
BonjourBrowserIntegrationTests.cs- Tests for Bonjour service browsingBonjourRegistrationIntegrationTests.cs- Tests for Bonjour service registrationWindowsMdnsBrowserIntegrationTests.cs- Tests Windows DNS-SD fallback service discovery
Purpose: Verify daemon/API integration for both Bonjour and Windows DNS-SD fallback paths.
Requires:
- Bonjour integration tests:
- Windows: Bonjour service (Apple Bonjour for Windows)
- macOS: Built-in mDNS support
- Linux: Avahi daemon
- WindowsMdns integration test:
- Windows 11+ host
- At least one discoverable mDNS service on the local network
WindowsMdnsBrowserIntegrationTests probes multiple common service types in parallel and passes if at least one returns a service. Override probe types with:
# PowerShell
$env:ARKANE_ZEROCONF_TEST_SERVICE_TYPES = "_http._tcp,_ipp._tcp,_printer._tcp"PlatformSpecificTests.cs- Tests for platform detection and native interop, including Linux Avahi availability, Linux systemd-resolved availability, and Windows Bonjour/DNS-SD availability
AzClientE2ETests.cs- Tests using the azclient CLI tool
PerformanceAndStressTests.cs- Performance and stress tests
dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName!~Integration"# Non-privileged: tests that require publish skip automatically
dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~SystemdResolvedProviderTests"
# Privileged: enables publish-path tests (requires polkit authorization)
sudo dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~SystemdResolvedProviderTests"Note: Running tests under sudo may leave build artifacts (obj/) owned by root.
Fix with: sudo find . -path '*/obj/*' | xargs sudo chown $USER
dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~WindowsMdnsBrowserIntegrationTests"Optional service type override:
# PowerShell
$env:ARKANE_ZEROCONF_TEST_SERVICE_TYPES = "_http._tcp;_ssh._tcp"
dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~WindowsMdnsBrowserIntegrationTests"You need an mDNS daemon running:
Windows:
- Download Bonjour from Apple (Bonjour for Windows)
- Install the service
- Verify the "Bonjour Service" is running in Services
macOS:
- Built-in support, no installation needed
Linux:
# Ubuntu/Debian
sudo apt-get install avahi-daemon
# Fedora/RHEL
sudo dnf install avahi
# Start the daemon
sudo systemctl start avahi-daemon# Run all tests
dotnet test Arkane.Zeroconf.Tests
# Run only integration tests
dotnet test Arkane.Zeroconf.Tests --filter "Arkane.Zeroconf.Tests.Integration"
# Run only Windows fallback integration test
dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~WindowsMdnsBrowserIntegrationTests"
# Run systemd-resolved provider tests (with sudo for publish paths)
sudo dotnet test Arkane.Zeroconf.Tests --filter "FullyQualifiedName~SystemdResolvedProviderTests"
# Run with detailed output
dotnet test Arkane.Zeroconf.Tests -v n
# Run with code coverage
dotnet-coverage collect -f cobertura -o coverage.cobertura.xml dotnet test Arkane.Zeroconf.Tests- Ensure network has discoverable mDNS services.
- Override
ARKANE_ZEROCONF_TEST_SERVICE_TYPESto match your environment. - Check local firewall prompts/allow rules for test process network access.
- Bonjour unavailable and no supported fallback available for current OS.
- On Windows, fallback lookup requires Windows 11+.
- On Linux, ensure systemd-resolved is running and
MulticastDNSis notnoin/etc/systemd/resolved.conf.
- Expected behavior (
PlatformNotSupportedException). - Check
ZeroconfSupport.CanPublishbefore attempting publish.
- Check
ZeroconfSupport.CanPublish— iffalse, polkit denied authorization. - Run with
sudoor configure a polkit rule fororg.freedesktop.resolve1. - Ensure
MulticastDNS=yes(not justresolve) in/etc/systemd/resolved.conf.
- The provider is only available on Linux with systemd-resolved running and
MulticastDNS≠no. - Check:
systemctl status systemd-resolvedandresolvectl status | grep -i multicast.