Skip to content

Instantly share code, notes, and snippets.

@palmerandy
Last active June 20, 2020 11:26
Show Gist options
  • Save palmerandy/17dcf71567005f2f2e810aa75de41bba to your computer and use it in GitHub Desktop.
Save palmerandy/17dcf71567005f2f2e810aa75de41bba to your computer and use it in GitHub Desktop.
C# End-to-end automated integration testing for SignalR Hub Action. More infromation available at https://andypalmer.dev/end-to-end-testing-mvc-signalr-api
using Gt.Fmc.IntegrationTests.Models;
public async Task SignalRExample(string hubName, string, hubAction, T exampleParam)
{
//ensure we are logged in so that MvcCookieContainer is set allowing us to auth with SignalR Hub.
await new MvcHttpClientHelper(MvcHttpClient).LoginHttpRequest();
using (var hubConnection = new HubConnection(Environment.WebSiteUrl))
{
var jobHub = hubConnection.CreateHubProxy(hubName);
hubConnection.CookieContainer = MvcCookieContainer;
await hubConnection.Start();
await jobHub.Invoke(hubAction, exampleParam));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment