|
@@ -0,0 +1,36 @@
|
|
|
|
|
+using System;
|
|
|
|
|
+using IvfTl.ControlHost.Debug;
|
|
|
|
|
+using IvfTl.ControlHost.Tests.Fakes;
|
|
|
|
|
+using IvfTl.Hardware;
|
|
|
|
|
+using Xunit;
|
|
|
|
|
+
|
|
|
|
|
+namespace IvfTl.ControlHost.Tests
|
|
|
|
|
+{
|
|
|
|
|
+ public class DebugStreamSessionTests
|
|
|
|
|
+ {
|
|
|
|
|
+ private DebugSessionManager NewMgr(FakeGate gate, DateTime now)
|
|
|
|
|
+ => new DebugSessionManager(_ => gate, () => now, ttlMs: 10000, log: null);
|
|
|
|
|
+
|
|
|
|
|
+ [Fact]
|
|
|
|
|
+ public void StreamBroken_DefaultsFalse()
|
|
|
|
|
+ {
|
|
|
|
|
+ var s = new DebugSession("sid1", 2, new FakeLease(new FakeGate(2, new FakeSerial()), new FakeSerial(), HardwareUser.OperateDebug), DateTime.UtcNow);
|
|
|
|
|
+ Assert.False(s.StreamBroken);
|
|
|
|
|
+ s.StreamBroken = true;
|
|
|
|
|
+ Assert.True(s.StreamBroken);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [Fact]
|
|
|
|
|
+ public void TryGet_ReturnsSession_ForValidSid()
|
|
|
|
|
+ {
|
|
|
|
|
+ var now = new DateTime(2026, 6, 24, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
|
+ var gate = new FakeGate(2, new FakeSerial());
|
|
|
|
|
+ var mgr = NewMgr(gate, now);
|
|
|
|
|
+ string sid = (string)mgr.Acquire(2).Result;
|
|
|
|
|
+
|
|
|
|
|
+ Assert.True(mgr.TryGet(sid, out var s));
|
|
|
|
|
+ Assert.Equal(2, s.HouseSn);
|
|
|
|
|
+ Assert.False(mgr.TryGet("nope", out _));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|