diff --git a/src/TeamsISO.Engine/Interop/NdiRuntimeProbe.cs b/src/TeamsISO.Engine/Interop/NdiRuntimeProbe.cs new file mode 100644 index 0000000..48e17cf --- /dev/null +++ b/src/TeamsISO.Engine/Interop/NdiRuntimeProbe.cs @@ -0,0 +1,35 @@ +namespace TeamsISO.Engine.Interop; + +/// +/// Result of an NDI runtime version check. +/// +public abstract record NdiRuntimeProbeResult +{ + public sealed record Match(string Version) : NdiRuntimeProbeResult; + public sealed record Mismatch(string Detected, string Expected) : NdiRuntimeProbeResult; +} + +/// +/// Compares the installed NDI runtime version (read via ) +/// against the version expected by the bundled SDK headers. Surfaces mismatches so the engine +/// can raise EngineAlert.NdiRuntimeMismatch. +/// +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); + } +} diff --git a/src/tests/TeamsISO.Engine.Tests/Interop/NdiRuntimeProbeTests.cs b/src/tests/TeamsISO.Engine.Tests/Interop/NdiRuntimeProbeTests.cs new file mode 100644 index 0000000..c4d9258 --- /dev/null +++ b/src/tests/TeamsISO.Engine.Tests/Interop/NdiRuntimeProbeTests.cs @@ -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(); + } + + [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(); + var mismatch = (NdiRuntimeProbeResult.Mismatch)result; + mismatch.Detected.Should().Be("5.6.0"); + mismatch.Expected.Should().Be("6.0.0"); + } +}