public async Task AddUserToGroupAsyncTest_WhenUserIdExistsAndUserIdInMembersIsEmpty_ReturnsGroupResponseModel()
        {
            var groupMockRepository   = new Mock <IGroupRepository>();
            var mockThreadRepository  = new Mock <IThreadRepository>();
            var contactMockRepository = new Mock <IContactRepository>();
            var mapper = GetMapperForGroupProfile();

            var userId      = _rnd.Next(111, 1000);
            var groupEntity = EntityModellers.CreateGroupEntity();

            groupEntity.Members.Add(userId);

            groupMockRepository.Setup(x => x.GetAsync(groupEntity.Id)).ReturnsAsync(groupEntity);
            groupMockRepository.Setup(x => x.AppendUsersAsync(groupEntity.Id, It.Is <IList <int> >(y => true))).ReturnsAsync(groupEntity);
            var expected = mapper.Map <GroupEntity, GroupResponseModel>(groupEntity);
            var newUsers = new List <int> {
                userId
            };
            var groupManager = new GroupManager(groupMockRepository.Object, mockThreadRepository.Object, mapper, contactMockRepository.Object);
            var actual       = await groupManager.AddUsersToGroupAsync(groupEntity.Id, newUsers);

            Assert.Equal(expected, actual, new LogicEqualityComparer <GroupResponseModel>());
            Assert.Contains(userId, actual.Members);

            groupMockRepository.Verify(x => x.AppendUsersAsync(groupEntity.Id, newUsers), Times.Never);

            groupMockRepository.VerifyAll();
        }
        public async Task AddUserToGroupAsyncTest_WhenGroupIdDoesntExists_ThrowsInvalidRequestException()
        {
            var groupMockRepository   = new Mock <IGroupRepository>();
            var mockThreadRepository  = new Mock <IThreadRepository>();
            var contactMockRepository = new Mock <IContactRepository>();
            var mapper = GetMapperForGroupProfile();

            var groupManager = new GroupManager(groupMockRepository.Object, mockThreadRepository.Object, mapper, contactMockRepository.Object);
            var exception    = await Assert.ThrowsAsync <InvalidRequestException>(() => groupManager.AddUsersToGroupAsync(Guid.NewGuid(), new List <int> {
                _rnd.Next(111, 1000)
            }));

            Assert.IsType <InvalidRequestException>(exception);
            Assert.StartsWith(ErrorConstants.InvalidInputMessage, exception.Message);

            groupMockRepository.VerifyAll();
        }