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); }
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); }
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)); }