public void CannotLikeIt_CommentNotFound() { var controller = new CommentLikeController( _userRepository.Object, _commentRepository.Object, _commentLikeRepository.Object) { ControllerContext = FakeController.GetContextWithIdentity("test1", "User") }; var result = controller.CommentLike(0) as ObjectResult; Assert.NotNull(result); Assert.IsType <NotFoundObjectResult>(result); Assert.Equal(404, result.StatusCode); Assert.NotNull(result.Value); Assert.Equal("Comment not found", result.Value); }
public void CanUnLikeComment() { var controller = new CommentLikeController( _userRepository.Object, _commentRepository.Object, _commentLikeRepository.Object) { ControllerContext = FakeController.GetContextWithIdentity("test1", "User") }; var result = controller.CommentLike(1) as ObjectResult; Assert.NotNull(result); Assert.IsType <OkObjectResult>(result); Assert.Equal(200, result.StatusCode); Assert.NotNull(result.Value); _commentLikeRepository.Verify(m => m.DeleteCommentLike(It.IsAny <CommentLike>()), Times.Once); var comment = result.Value as ItemViewData <Comment>; Assert.NotNull(comment); }