public async void PartiallyUpdateComment_ReturnsBadRequestObjectResult_WhenTheCommentIdIsInvalid() { //Arrange var controller = new PostCommentsController(_loggerMock.Object, _mockPostService.Object, _mockUserService.Object, _mockCommentService.Object); //Act var result = await controller.PartiallyUpdateComment(ConstIds.InvalidGuid, GetJsonPatchDocument()); //Assert var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(result); Assert.Equal($"{ConstIds.InvalidGuid} is not valid guid.", badRequestObjectResult.Value); }
public async void PartiallyUpdateComment_ReturnsBadRequestResult_WhenTheCommentHasNotBeenUpdated() { //Arrange _mockCommentService.Setup(Service => Service.TryUpdatePostCommentAsync(It.IsAny <Guid>(), It.IsAny <JsonPatchDocument <PostCommentToUpdateDto> >())) .ReturnsAsync(false) .Verifiable(); var controller = new PostCommentsController(_loggerMock.Object, _mockPostService.Object, _mockUserService.Object, _mockCommentService.Object); //Act var result = await controller.PartiallyUpdateComment(ConstIds.ExampleCommentId, GetJsonPatchDocument()); //Assert var badRequestResult = Assert.IsType <BadRequestResult>(result); _mockCommentService.Verify(); }
public async void PartiallyUpdateComment_ReturnsInternalServerErrorResult_WhenExceptionThrownInService() { //Arrange _mockCommentService.Setup(Service => Service.TryUpdatePostCommentAsync(It.IsAny <Guid>(), It.IsAny <JsonPatchDocument <PostCommentToUpdateDto> >())) .Throws(new ArgumentNullException(nameof(Guid))) .Verifiable(); var controller = new PostCommentsController(_loggerMock.Object, _mockPostService.Object, _mockUserService.Object, _mockCommentService.Object); //Act var result = await controller.PartiallyUpdateComment(ConstIds.ExampleCommentId, GetJsonPatchDocument()); //Assert var internalServerErrorResult = Assert.IsType <StatusCodeResult>(result); Assert.Equal(StatusCodes.Status500InternalServerError, internalServerErrorResult.StatusCode); _mockCommentService.Verify(); }