Is there a test suite for custom SignalR clients? #65990
|
Forwarding my question from Stack Overflow here. I'm making a custom SignalR client in C++ due to the official one being abandoned including its dependencies. I would like to test my client library against some form of test suite that implements whatever valid SignalR can output to the client in all protocols it has. Is there any? |
Replies: 1 comment
|
There is not currently a standalone, language-neutral SignalR client conformance package in the ASP.NET Core repository. However, the repository contains the pieces needed to build a useful conformance harness for a C++ client. 1. Treat the protocol specifications as the normative layer
The handshake deserves its own tests: it is always JSON, must be the first message, and is terminated by 2. Reuse the official serialization vectorsThe protocol test bases contain concrete valid and invalid frames for every hub message type. They are the closest thing to a reusable protocol test corpus:
I would extract those cases into language-neutral fixtures such as JSON metadata plus raw/base64 wire payloads. For each fixture, test both directions:
Also include malformed/truncated frames, unknown message types, extra data, duplicate invocation IDs, completion-with-result-and-error, record separators, and multiple messages in one receive buffer. 3. Run interoperability tests against the official serverMicrosoft’s own client functional tests start a real ASP.NET Core server and exercise JSON/MessagePack over WebSockets, SSE and long polling. The test host and endpoints are here:
You can create a small .NET test-server executable modeled on that
This gives you three separate guarantees: codec correctness from the vectors, state-machine correctness from negative tests, and real interoperability against the current ASP.NET Core server. Pin the ASP.NET Core commit used to obtain the fixtures, and periodically test against the latest supported release so protocol changes are visible rather than silently changing your expected data. If this resolves what you were looking for, you can mark it as the accepted answer so future client implementers can find the test approach quickly. |
There is not currently a standalone, language-neutral SignalR client conformance package in the ASP.NET Core repository. However, the repository contains the pieces needed to build a useful conformance harness for a C++ client.
1. Treat the protocol specifications as the normative layer
https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/HubProtocol.md
https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
The handshake deserves its own tests: it …