Ejemplo n.º 1
0
        public void ShouldGetCommentLikes()
        {
            var commentLikes = _commentLikes.Where(a => a.CommentId == 1).ToList();
            _commentLikeRepository = new Mock<ICommentLikeRepository>();
            _commentLikeRepository.Setup(a => a.Find(It.IsAny<Expression<Func<CommentLike, bool>>>(), true))
                .Returns(commentLikes);

            _commentLikesLogic = new CommentLikesLogic(_commentLikeRepository.Object);

            var result = _commentLikesLogic.Get(1);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(1, result[0].CommentId);
            Assert.AreEqual(1, result[1].CommentId);
        }
Ejemplo n.º 2
0
        public void ShouldReturnEmptyListWhenGetCommentLikesFoundNoRecords()
        {
            _commentLikeRepository = new Mock<ICommentLikeRepository>();
            _commentLikeRepository.Setup(a => a.Find(It.IsAny<Expression<Func<CommentLike, bool>>>(), true))
                .Returns(new List<CommentLike>());

            _commentLikesLogic = new CommentLikesLogic(_commentLikeRepository.Object);

            var result = _commentLikesLogic.Get(1);

            Assert.NotNull(result);
            Assert.AreEqual(0, result.Count);
        }
Ejemplo n.º 3
0
        public void ShouldThrowExceptionWhenGetCommentLikesFails()
        {
            _commentLikeRepository = new Mock<ICommentLikeRepository>();
            _commentLikeRepository.Setup(a => a.Find(It.IsAny<Expression<Func<CommentLike, bool>>>(), true))
                .Throws(new Exception());

            _commentLikesLogic = new CommentLikesLogic(_commentLikeRepository.Object);

            Assert.Throws<BlogException>(() => _commentLikesLogic.Get(1));
        }