Ejemplo n.º 1
0
        public void Test_CommentDeleteRequest_Validate_Throws_Exceptions()
        {
            // id is null
            var request = new CommentDeleteRequest();

            Action act = () => request.Validate();

            act.Should().Throw <ArgumentNullException>();

            // empty id
            request = new CommentDeleteRequest {
                Id = string.Empty
            };

            act = () => request.Validate();
            act.Should().Throw <ArgumentException>();

            // id with spaces
            request = new CommentDeleteRequest {
                Id = "invalid id"
            };

            act = () => request.Validate();
            act.Should().Throw <ArgumentException>();
        }
Ejemplo n.º 2
0
        public void Test_CommentDeleteRequest_Returns_Valid_UriPathParameters()
        {
            // only id
            var request = new CommentDeleteRequest {
                Id = "123"
            };

            request.GetUriPathParameters().Should().NotBeNull()
            .And.HaveCount(1)
            .And.Contain(new Dictionary <string, object>
            {
                ["id"] = "123"
            });
        }
        public async Task <CommentDeleteResponse> Delete(CommentDeleteRequest request)
        {
            //foreach (var id in request.Ids)
            //{
            //    var deleting = _commentData.Query.First(x => x.Id == id);
            //    await base.BaseBeforeDeleteAsync(deleting, request.RequestOwner);
            //    await _commentData.DeleteAsync(id);
            //    await base.BaseAfterDeleteAsync(deleting, request.RequestOwner);
            //}

            await _commentData.DeleteAsync(request.Ids);

            return(new CommentDeleteResponse()
            {
                Access = ResponseAccess.Granted
            });
        }
Ejemplo n.º 4
0
 public IActionResult Delete([FromBody] CommentDeleteRequest request)
 {
     try
     {
         var userId = _authenticationService.GetAuthenticatedUserId(User);
         _commentService.Delete(request.CommentId, userId);
         return(new ObjectResult(new
         {
             StatusCode = ResponseConstants.Success,
         }));
     }
     catch (CommentNotFoundException)
     {
         return(new ObjectResult(new Result {
             StatusCode = ResponseConstants.Unknown
         }));
     }
     catch (Exception)
     {
         return(new ObjectResult(new Result {
             StatusCode = ResponseConstants.Unknown
         }));
     }
 }
Ejemplo n.º 5
0
        public void Test_CommentDeleteRequest_Returns_Valid_RequestObjectType()
        {
            var request = new CommentDeleteRequest();

            request.RequestObjectType.Should().Be(RequestObjectType.Comments);
        }
Ejemplo n.º 6
0
        public void Test_CommentDeleteRequest_Has_AuthorizationRequirement_Required()
        {
            var requestMock = new CommentDeleteRequest();

            requestMock.AuthorizationRequirement.Should().Be(AuthorizationRequirement.Required);
        }
Ejemplo n.º 7
0
        public void Test_CommentDeleteRequest_Has_Valid_UriTemplate()
        {
            var request = new CommentDeleteRequest();

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