Esempio n. 1
0
        public async Task DeleteGroupByIdAsync_WhenGroupIdDoesntExists_ReturnsGroupResponseWithGroupRemoved()
        {
            var groupMockRepository   = new Mock <IGroupRepository>();
            var mockThreadRepository  = new Mock <IThreadRepository>();
            var contactMockRepository = new Mock <IContactRepository>();

            var mapper = GetMapperForGroupProfile();

            var groupEntity    = EntityModellers.CreateGroupEntity();
            var chatUserEntity = EntityModellers.CreateChatUserEntity();
            var threadEntity   = EntityModellers.CreateThreadEntity();

            var expected = mapper.Map <GroupEntity, GroupResponseModel>(new GroupEntity());

            groupMockRepository.Setup(x => x.DeleteAsync(groupEntity.Id)).ReturnsAsync(new GroupEntity());
            var groupManager = new GroupManager(groupMockRepository.Object, mockThreadRepository.Object, mapper, contactMockRepository.Object);
            var actual       = await groupManager.DeleteGroupByIdAsync(groupEntity.Id);

            Assert.Equal(expected, actual, new LogicEqualityComparer <GroupResponseModel>());
            mockThreadRepository.Verify(x => x.DeleteByMultiIdAsync(groupEntity.Id), Times.Never);

            groupMockRepository.VerifyAll();
            mockThreadRepository.VerifyAll();
        }