public void Test_CommentUnlikeRequest_Validate_Throws_Exceptions() { // id is null var request = new CommentUnlikeRequest(); Action act = () => request.Validate(); act.Should().Throw <ArgumentNullException>(); // empty id request = new CommentUnlikeRequest { Id = string.Empty }; act = () => request.Validate(); act.Should().Throw <ArgumentException>(); // id with spaces request = new CommentUnlikeRequest { Id = "invalid id" }; act = () => request.Validate(); act.Should().Throw <ArgumentException>(); }
public void Test_CommentUnlikeRequest_Returns_Valid_UriPathParameters() { // only id var request = new CommentUnlikeRequest { Id = "123" }; request.GetUriPathParameters().Should().NotBeNull() .And.HaveCount(1) .And.Contain(new Dictionary <string, object> { ["id"] = "123" }); }
public IActionResult Unlike([FromBody] CommentUnlikeRequest request) { try { var userId = _authenticationService.GetAuthenticatedUserId(User); _commentService.Unlike(request.CommentId, userId); return(new ObjectResult(new { StatusCode = ResponseConstants.Success, })); } catch (CommentNotLikedException) { return(new ObjectResult(new Result { StatusCode = ResponseConstants.Unknown })); } catch (Exception) { return(new ObjectResult(new Result { StatusCode = ResponseConstants.Unknown })); } }
public void Test_CommentUnlikeRequest_Returns_Valid_RequestObjectType() { var request = new CommentUnlikeRequest(); request.RequestObjectType.Should().Be(RequestObjectType.Comments); }
public void Test_CommentUnlikeRequest_Has_AuthorizationRequirement_Required() { var requestMock = new CommentUnlikeRequest(); requestMock.AuthorizationRequirement.Should().Be(AuthorizationRequirement.Required); }
public void Test_CommentUnlikeRequest_Has_Valid_UriTemplate() { var request = new CommentUnlikeRequest(); request.UriTemplate.Should().Be("comments/{id}/like"); }