using MxGateway.Contracts.Proto; using MxGateway.Server.Sessions; namespace MxGateway.Tests.Gateway.Sessions; /// /// PR A.6 / A.7 — pins the not-yet-wired dispatcher's behaviour: /// AcknowledgeAsync returns OK with a worker-pending diagnostic and /// QueryActiveAlarmsAsync yields an empty stream. Production /// WorkerAlarmRpcDispatcher (dev-rig follow-up) replaces this /// impl in DI without changing the gateway handler shape. /// public sealed class NotWiredAlarmRpcDispatcherTests { [Fact] public async Task AcknowledgeAsync_WhenNotWired_ReturnsOkWithWorkerPendingDiagnostic() { IAlarmRpcDispatcher dispatcher = new NotWiredAlarmRpcDispatcher(); AcknowledgeAlarmReply reply = await dispatcher.AcknowledgeAsync( new AcknowledgeAlarmRequest { SessionId = "session-1", ClientCorrelationId = "corr-1", AlarmFullReference = "Tank01.Level.HiHi", Comment = "investigating", OperatorUser = "alice", }, CancellationToken.None); Assert.Equal(ProtocolStatusCode.Ok, reply.ProtocolStatus.Code); Assert.Equal("session-1", reply.SessionId); Assert.Equal("corr-1", reply.CorrelationId); Assert.Contains("worker", reply.DiagnosticMessage, StringComparison.OrdinalIgnoreCase); } [Fact] public async Task QueryActiveAlarmsAsync_WhenNotWired_YieldsNoSnapshots() { IAlarmRpcDispatcher dispatcher = new NotWiredAlarmRpcDispatcher(); int count = 0; await foreach (ActiveAlarmSnapshot _ in dispatcher.QueryActiveAlarmsAsync( new QueryActiveAlarmsRequest { SessionId = "session-1" }, CancellationToken.None)) { count++; } Assert.Equal(0, count); } }