9582de077b
Tests-007: TestServerCallContext and stream-writer/constraint helpers were copy-pasted across five test files. Consolidated into a shared MxGateway.Tests.TestSupport namespace; duplicates deleted. Tests-008: renamed snake_case alarm-test methods to PascalCase Method_Condition_Result and dropped redundant usings. Re-triaged two inaccurate sub-claims (the "wnwrap" name and a required CompilerServices using). Tests-009: corrected three copy-paste-mismatched XML <summary> comments in SessionManagerTests. Tests-010: added the missing anonymous-localhost security negatives — bypass disallowed, and loopback-allowed from a remote address. Tests-011: SessionWorkerClientFactoryFakeWorkerTests discarded worker tasks. The test class now tracks each launcher and observes its task in DisposeAsync. Tests-012: added xunit.runner.json pinning collection parallelism and documented the ephemeral-port convention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using MxGateway.Contracts.Proto;
|
|
using MxGateway.Server.Sessions;
|
|
|
|
namespace MxGateway.Tests.Gateway.Sessions;
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// <c>WorkerAlarmRpcDispatcher</c> (dev-rig follow-up) replaces this
|
|
/// impl in DI without changing the gateway handler shape.
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|