[SignalR] Better integration with TestServer
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
Right now, it's only possible to use TestServer with the non-WebSockets transports because we only provide a way to replace the `HttpMessageHandler`. We should consider providing a way to provide a `WebSocket` "factory" so that we can integrate properly with TestServer.
It might be most appropriate here to add an alternative to `WithUrl` on `HubConnectionBuilder`. Consider this possible test code:
```csharp
var server = new TestServer(webHostBuilder);
var connection = new HubConnectionBuilder()
.WithTestServer(server, HttpTransportType.WebSockets, o => {
// Assorted other HttpConnectionOptions
})
.Build();
```
It would be relatively simple to add this API once we have a way to swap out the WebSocket, though we'd probably need to do so in a new assembly to avoid layering issues.
Contributor guide
Assessment
This issue has not been assessed yet.