2.0 KiB
Gateway Testing
Gateway tests run without installed MXAccess by using fake workers, fake transports, and in-process gRPC service fakes. Live MXAccess verification belongs in opt-in integration tests because it depends on installed COM components and provider state.
Fake Worker Harness
FakeWorkerHarness in src/MxGateway.Tests/Gateway/Workers/Fakes/ provides an
in-process worker side for named-pipe IPC tests. It uses the same
WorkerFrameReader, WorkerFrameWriter, and WorkerEnvelope contract as the
gateway so tests exercise real frame validation and worker-client state changes.
Use the harness when a gateway or session test needs worker behavior without
starting MxGateway.Worker.exe or loading MXAccess COM. The harness scripts:
WorkerHelloandWorkerReadystartup,- command replies with matching correlation ids,
- ordered
WorkerEventframes, WorkerFaultframes,- shutdown acknowledgements,
- malformed protobuf payloads and oversized frame headers,
- slow or hung workers by withholding a reply.
Session-level tests can connect the harness to the pipe created by
SessionWorkerClientFactory with ConnectToGatewayPipeAsync. Lower-level
WorkerClient tests can use CreateConnectedPairAsync to create both pipe ends
inside the test.
Focused Commands
Run the fake worker tests after changing gateway worker IPC, session startup, or event streaming behavior:
dotnet test src/MxGateway.Tests/MxGateway.Tests.csproj --filter FullyQualifiedName~FakeWorkerHarnessTests
dotnet test src/MxGateway.Tests/MxGateway.Tests.csproj --filter FullyQualifiedName~SessionWorkerClientFactoryFakeWorkerTests
Run the gateway test project after shared gateway test infrastructure changes:
dotnet test src/MxGateway.Tests/MxGateway.Tests.csproj