I'm using Moq to build up a UnitTest framework for my SignalR 2.x application. I am currently mocking up my Clients by:
var mockClients = new Mock<IHubCallerConnectionContext>();
Clients = mockClients.Object;
In order to test, I need to test sending messages by Group:
Clients.Group(groupName).sendSomeMessage(message);
How do I add Group support to my mocked up Client?
Check this: https://github.com/SignalR/SignalR/blob/release/tests/Microsoft.AspNet.SignalR.Tests/Server/Hubs/HubFacts.cs
If you want to check that a certain group was notified you should be able to do something like this (this is SignalR 2):
The code above is checking that my
NotificationsHub.RaiseAlert(string groupId)
method is only triggered on the client side for the specificgroupId
I pass in.This is the hub that's being tested:
You could refer to this tutorial by the SingalR team.