Last active
June 20, 2020 11:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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