public void AddLike_addPositiveLike_commentPopertyNegativeLikePlus1()
        {
            // Arrange
            const int userId = 1;
            const int commentId = 2;
            const bool isPositiveLike = false;
            var commentBo = new CommentBo(_commentRepo, _commentLikesRepo);

            _commentRepo
                .GetItem(Arg.Is<int>(x => x >= 1))
                .Returns(new Comment
                {
                    Id = commentId,
                    PostId = 1,
                    UserId = 1,
                });

            _commentLikesRepo
                .Query()
                .Returns(new List<CommentVote>
                    {
                            new CommentVote
                            {
                                Id = 1,
                                UserId = 3,
                                CommentId = 1
                            },
                            new CommentVote
                            {
                                Id = 2,
                                UserId = 3,
                                CommentId = 2
                            }
                    }
                .AsQueryable());

            // Act
            commentBo.AddLike(userId, commentId, isPositiveLike);

            // Assert
            var commennt = _commentRepo.GetItem(1);
            Assert.AreEqual(commennt.NegativeLike, 1);
            _commentRepo
                .Received(1)
                    .Save();
        }
        public void AddComment_comentCreatedWithCorrectParamValue()
        {
            // Arrange
            const int userId = 2;
            const int postId = 2;
            const string content = "abc";
            var commentBo = new CommentBo(_commentRepo, _commentLikesRepo);

            // Act
            commentBo.AddComment(userId, postId, content);

            // Assert
            _commentRepo
                .Received(1)
                .Create(Arg.Is<Comment>(x =>
                    x.UserId == userId &&
                    x.PostId == postId &&
                    x.Content == content));
        }
        public void GetCommentsQueryByPostId_havePostsWithId2AndId3_postWithId2Returned()
        {
            // Arrange
            const int commentId = 2;
            var commentBo = new CommentBo(_commentRepo, _commentLikesRepo);
            _commentRepo.Query()
                .Returns(new List<Comment>
                {
                    new Comment
                    {
                        Id = commentId,
                    },
                    new Comment()
                    {
                        Id = commentId+1,
                    }
                }.AsQueryable());

            // Act
            var query = commentBo.GetCommentsQueryByPostId(2);

            // Assert
            foreach (var q in query)
            {
                Assert.AreEqual(commentId, q.Id);
            }
        }
        public void AddLike_likeAlreadyExist_likeNotAdded()
        {
            // Arrange
            const int userId = 2;
            const int commentId = 2;
            const bool isPositiveLike = false;
            var commentBo = new CommentBo(_commentRepo, _commentLikesRepo);

            _commentLikesRepo
                    .Query()
                    .Returns(new List<CommentVote>
                        {
                            new CommentVote
                            {
                                Id = 1,
                                UserId = 1,
                                CommentId = 1
                            },
                            new CommentVote
                            {
                                Id = 2,
                                UserId = 2,
                                CommentId = 2
                            }
                        }
                    .AsQueryable());

            // Act
            commentBo.AddLike(userId, commentId, isPositiveLike);

            // Assert
            _commentLikesRepo
                .Received(0)
                  .Create(Arg.Is<CommentVote>(x =>
                        x.UserId == 5 &&
                        x.CommentId == commentId));
        }