public void GetComments_WhenEmptyContext_ReturnsEmptyList()
        {
            // Arrange
            var commentsCount = _cloudDbContext.Comments.Count();

            // Act
            var comments = _cloudManager.GetComments().ToList();

            // Assert
            Assert.Empty(comments);
            Assert.Equal(comments.Count, commentsCount);
        }
        ///<inheritdoc/>
        public async Task SynchronizeForAddingCommentsAsync()
        {
            _logger.LogInformation(Application.Resources.CommentSynchronizationService.StartSynchronizationForUpdationComment);

            var cloudComments = await _cloudManager.GetComments().ToListAsync();

            var applicationComments = (await _commentManager.GetCommentsWithoutTrackingAsync()).ToList();

            var cloudCommentsIds       = cloudComments.Select(c => c.Id).ToList();
            var applicationCommentsIds = applicationComments.Select(c => c.CloudId).ToList();

            var idsForSync = cloudCommentsIds.Except(applicationCommentsIds);

            var commentsForSync = cloudComments.Join(idsForSync,
                                                     cloudComment => cloudComment.Id,
                                                     newId => newId,
                                                     (cloudComment, newId) => cloudComment);

            if (commentsForSync.Any())
            {
                foreach (var comment in commentsForSync)
                {
                    var applicationPosts = await _postManager.GetPostsWithoutTrackingAsync();

                    var post = applicationPosts.FirstOrDefault(post => post.CloudId == comment.PostId);

                    if (post != null)
                    {
                        var commentDto = new CommentDto
                        {
                            CloudId = comment.Id,
                            PostId  = post.Id,
                            Email   = comment.Email,
                            Name    = comment.Name
                        };

                        await _commentManager.CreateCommentAsync(commentDto);
                    }
                    else
                    {
                        _logger.LogError(ErrorMessages.CommentSyncService_AddingCommentError, comment.PostId);
                    }
                }
            }

            _logger.LogInformation(Application.Resources.CommentSynchronizationService.EndSynchronizationForUpdationComment);
        }
        /// <inheritdoc/>
        public async Task AddAsync()
        {
            _logger.LogInformation(SyncMessage.CommentAddStart);

            var commentsCloud = await _cloudManager.GetComments().ToListAsync();

            var commentsApp = (await _commentManager.GetAllAsync()).ToList();
            var postsApp    = (await _postManager.GetAllAsync()).ToList();

            var commentCloudIds = commentsCloud.Select(c => c.Id);
            var commentAppIds   = commentsApp.Select(c => c.CloudId);

            var newIds   = commentCloudIds.Except(commentAppIds);
            var comments = commentsCloud.Join(
                newIds,
                commentCloud => commentCloud.Id,
                id => id,
                (commentCloud, id) => commentCloud);

            if (comments.Any())
            {
                foreach (var comment in comments)
                {
                    var post = postsApp.FirstOrDefault(p => p.CloudId == comment.PostId);

                    if (post != null)
                    {
                        var commentDto = new CommentDto
                        {
                            CloudId = comment.Id,
                            PostId  = post.Id,
                            Name    = comment.Name,
                            Email   = comment.Email,
                            Body    = comment.Body
                        };

                        await _commentManager.CreateAsync(commentDto);
                    }
                    else
                    {
                        _logger.LogError(SyncMessage.CommentAddError, comment.PostId);
                    }
                }
            }

            _logger.LogInformation(SyncMessage.CommentAddEnd);
        }