Example #1
0
        public async Task LeaveGroup_Success_NotifyCurrentAndAllConnection()
        {
            var testPayload = new UserWssPayload {
                GroupId = TestGroupId
            };
            var testGroup = new Group {
                Id = TestGroupId
            };

            _chatServiceMock
            .Setup(s => s.LeaveGroupAsync(TestUserId, TestGroupId))
            .Returns(Task.CompletedTask);
            _chatServiceMock
            .Setup(s => s.GetGroupAsync(testGroup.Id))
            .ReturnsAsync(testGroup);

            await _target.LeaveGroup(testPayload);

            AssertMessageSentToCurrentConnection(ChatHub.LeaveSuccessMessage,
                                                 content => (string)content == TestGroupId);
            AssertMessageSentToAllConnections(ChatHub.MemberLeftMessage,
                                              content => ((MemberChangeResponse)content).Group == testGroup);
        }