public void DeleteAlbum_Should_ReturnOk() { var commentId = 1; mockService.Setup(s => s.RemoveCommentAsync(commentId, userId)).Verifiable(); controller.DeleteComment(commentId).Result.Should().BeOfType <OkResult>(); mockService.Verify(); }
public void DeleteComment_Returns_404NotFound_WhenNonExistentResourceIDSubmitted() { //Arrange iCommentService.Setup(serv => serv.GetCommentById(0)).Returns(() => null); var controller = new CommentController(iCommentService.Object, mapper); //Act var result = controller.DeleteComment(0); //Assert Assert.IsType <NotFoundResult>(result); }
public void DeleteComment_Returns200OK_WhenValidResourceIDSubmitted() { //Arrange iCommentService.Setup(serv => serv.GetCommentById(1)).Returns(new Comment { CommentId = 1, Description = "Mock", Date = new DateTime(), EventId = 1 }); var controller = new CommentController(iCommentService.Object, mapper); //Act var result = controller.DeleteComment(1); //Assert Assert.IsType <NoContentResult>(result); }
public void CanDeleteComment() { var controller = new CommentController( _userRepository.Object, _postRepository.Object, _commentRepository.Object, _commentLikeRepository.Object) { ControllerContext = FakeController.GetContextWithIdentity("test1", "User") }; var result = controller.DeleteComment(1) as ObjectResult; _commentRepository.Verify(c => c.DeleteComment(It.IsAny <Comment>()), Times.Once); Assert.NotNull(result); Assert.IsType <OkObjectResult>(result); Assert.Equal(200, result.StatusCode); Assert.NotNull(result.Value); Assert.Equal("Deleted", result.Value); }
public void CannotDeleteComment_CommentNotFound() { var controller = new CommentController( _userRepository.Object, _postRepository.Object, _commentRepository.Object, _commentLikeRepository.Object) { ControllerContext = FakeController.GetContextWithIdentity("test2", "User") }; var result = controller.DeleteComment(1) as ObjectResult; _commentRepository.Verify(c => c.DeleteComment(It.IsAny <Comment>()), Times.Never); 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 UpdateCommentBad() { var retorno = commentController.DeleteComment(commentOne.IdComment); Assert.IsType <BadRequestResult>(retorno); }