示例#1
0
        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>();
        }
示例#2
0
        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"
            });
        }
示例#3
0
 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
         }));
     }
 }
示例#4
0
        public void Test_CommentUnlikeRequest_Returns_Valid_RequestObjectType()
        {
            var request = new CommentUnlikeRequest();

            request.RequestObjectType.Should().Be(RequestObjectType.Comments);
        }
示例#5
0
        public void Test_CommentUnlikeRequest_Has_AuthorizationRequirement_Required()
        {
            var requestMock = new CommentUnlikeRequest();

            requestMock.AuthorizationRequirement.Should().Be(AuthorizationRequirement.Required);
        }
示例#6
0
        public void Test_CommentUnlikeRequest_Has_Valid_UriTemplate()
        {
            var request = new CommentUnlikeRequest();

            request.UriTemplate.Should().Be("comments/{id}/like");
        }