public async Task CreateNewGroupAsyncTest_WhenMemberCreatedExists_ReturnsGroupResponseModel() { var groupMockRepository = new Mock <IGroupRepository>(); var mockThreadRepository = new Mock <IThreadRepository>(); var contactMockRepository = new Mock <IContactRepository>(); var mapper = GetMapperForGroupProfile(); var groupEntity = EntityModellers.CreateGroupEntity(); var groupNewrequestModel = EntityModellers.CreateNewGroupRequestModel(); var groupResponse = mapper.Map <NewGroupRequestModel, GroupEntity>(groupNewrequestModel); groupResponse.Members = new List <int> { groupNewrequestModel.CreatedUserId }; groupMockRepository.Setup(x => x.CreateAsync(It.Is <GroupEntity>(y => y.Name == groupNewrequestModel.Name && y.CreatedUserId == groupNewrequestModel.CreatedUserId && y.CreatedUsername == groupNewrequestModel.CreatedUserName))).ReturnsAsync(groupResponse); var expected = mapper.Map <GroupEntity, GroupResponseModel>(groupResponse); var groupManager = new GroupManager(groupMockRepository.Object, mockThreadRepository.Object, mapper, contactMockRepository.Object); var actual = await groupManager.CreateNewGroupAsync(groupNewrequestModel); Assert.Equal(expected, actual, new LogicEqualityComparer <GroupResponseModel>()); }