public void Should_have_error_when_comment_text_is_empty()
        {
            var postRepository = new Mock <IPostRepository>();
            var validator      = new AddCommentCommandValidator(postRepository.Object);
            var command        = new AddCommentCommand(Guid.NewGuid(), "", false);

            validator.ShouldHaveValidationErrorFor(x => x.Text, command);
        }
        public void Setup_OkState()
        {
            _invitationValidatorMock = new Mock <IInvitationValidator>();
            _invitationValidatorMock.Setup(inv => inv.IpoExistsAsync(_invitationId, default)).Returns(Task.FromResult(true));
            _command = new AddCommentCommand(
                _invitationId,
                _commentText);

            _dut = new AddCommentCommandValidator(_invitationValidatorMock.Object);
        }
        public void Should_have_error_when_post_does_not_exist()
        {
            var postId = Guid.NewGuid();

            var postRepository = new Mock <IPostRepository>();

            postRepository.Setup(x => x.GetById(postId)).Returns <Post>(null);

            var validator = new AddCommentCommandValidator(postRepository.Object);
            var command   = new AddCommentCommand(postId, "", false);

            validator.ShouldHaveValidationErrorFor(x => x.PostId, command);
        }
Ejemplo n.º 4
0
 public override bool Validate()
 {
     ValidationResult = new AddCommentCommandValidator().Validate(this);
     return(ValidationResult.IsValid);
 }