feat(interop): add NdiRuntimeProbe with version-mismatch result
Some checks failed
CI / build-and-test (push) Failing after 27s

This commit is contained in:
Zac Gaetano 2026-05-07 15:24:31 +00:00
parent 798a5abd64
commit e318514202
2 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,35 @@
namespace TeamsISO.Engine.Interop;
/// <summary>
/// Result of an NDI runtime version check.
/// </summary>
public abstract record NdiRuntimeProbeResult
{
public sealed record Match(string Version) : NdiRuntimeProbeResult;
public sealed record Mismatch(string Detected, string Expected) : NdiRuntimeProbeResult;
}
/// <summary>
/// Compares the installed NDI runtime version (read via <see cref="INdiInterop.GetRuntimeVersion"/>)
/// against the version expected by the bundled SDK headers. Surfaces mismatches so the engine
/// can raise <c>EngineAlert.NdiRuntimeMismatch</c>.
/// </summary>
public sealed class NdiRuntimeProbe
{
private readonly INdiInterop _interop;
private readonly string _expectedVersion;
public NdiRuntimeProbe(INdiInterop interop, string expectedVersion)
{
_interop = interop;
_expectedVersion = expectedVersion;
}
public NdiRuntimeProbeResult Probe()
{
var detected = _interop.GetRuntimeVersion();
return string.Equals(detected, _expectedVersion, StringComparison.Ordinal)
? new NdiRuntimeProbeResult.Match(detected)
: new NdiRuntimeProbeResult.Mismatch(detected, _expectedVersion);
}
}

View file

@ -0,0 +1,32 @@
using TeamsISO.Engine.Interop;
using TeamsISO.Engine.Tests.Fakes;
namespace TeamsISO.Engine.Tests.Interop;
public class NdiRuntimeProbeTests
{
[Fact]
public void Probe_VersionsMatch_ReturnsMatch()
{
var interop = new FakeNdiInterop { RuntimeVersion = "6.0.0" };
var probe = new NdiRuntimeProbe(interop, expectedVersion: "6.0.0");
var result = probe.Probe();
result.Should().BeOfType<NdiRuntimeProbeResult.Match>();
}
[Fact]
public void Probe_VersionsDiffer_ReturnsMismatchWithBoth()
{
var interop = new FakeNdiInterop { RuntimeVersion = "5.6.0" };
var probe = new NdiRuntimeProbe(interop, expectedVersion: "6.0.0");
var result = probe.Probe();
result.Should().BeOfType<NdiRuntimeProbeResult.Mismatch>();
var mismatch = (NdiRuntimeProbeResult.Mismatch)result;
mismatch.Detected.Should().Be("5.6.0");
mismatch.Expected.Should().Be("6.0.0");
}
}