public void ShouldHaveReceiverAfterAddReceiver()
        {
            var mockRepo    = new Mock <IConnectedClientRepository <HubConnectedClient> >();
            var hub         = new SignalRMessageHubService(mockRepo.Object);
            var mockRequest = new Mock <IRequest>();

            hub.Context = new HubCallerContext(mockRequest.Object, "123");
            var mockGroups = new Mock <IGroupManager>();

            hub.Groups = mockGroups.Object;

            var receiverId = Guid.NewGuid();

            hub.AddReceiver(new ConnectedClientData(receiverId, null));
            mockGroups.Verify(m => m.Add(It.IsAny <string>(), "__receivers"), Times.Once);
        }
        public void ShouldNotTriggerReceiveCallbackFromSameHubId()
        {
            var mockRepo    = new Mock <IConnectedClientRepository <HubConnectedClient> >();
            var hub         = new SignalRMessageHubService(mockRepo.Object);
            var mockRequest = new Mock <IRequest>();

            hub.Context = new HubCallerContext(mockRequest.Object, "123");
            var mockGroups = new Mock <IGroupManager>();

            hub.Groups = mockGroups.Object;
            var mockClients = new Mock <IHubCallerConnectionContext <dynamic> >();

            hub.Clients = mockClients.Object;

            var  receiver     = new Mock <IMessageHubServiceReceiver>();
            Guid excludedGuid = Guid.NewGuid();

            receiver.SetupGet(r => r.Id).Returns(excludedGuid);
            hub.AddReceiver(new ConnectedClientData(excludedGuid, null));
            hub.Send(excludedGuid, Message.Create().WithData("Test"));
            receiver.Verify(r => r.Receive(excludedGuid, It.IsAny <Message>()), Times.Never);
        }