Exemple #1
0
        public void ValidComment()
        {
            var comment = new Comment()
            {
                Txt       = "asdassadda",
                UserID    = "correct_user_id",
                MemeRefId = 1
            };

            ValidationResult result = commentValidator.Validate(comment);

            Assert.True(result.IsValid);
        }
Exemple #2
0
 public void Check_CommentTitle_Valid(int textLength)
 {
     string text = GetStringWithDesiredLength(textLength);
     var validator = new CommentValidator();
     string[] errors;
     Assert.True(validator.Validate(Comment.Create(new CommentState { Text = text }), out errors));
 }
Exemple #3
0
        public void CommentValidator_ThrowsInvalidValueLength()
        {
            CommentModel model = new CommentModel
            {
                PostId = new Guid("9834d7b9-618d-435b-b86e-d9e861111738"),
                Value  = "too small"
            };
            CommentValidator validator = new CommentValidator();

            validator.Validate(model);
        }
Exemple #4
0
        public void CommentValidator_ThrowsEmptyOrNullValue()
        {
            CommentModel model = new CommentModel
            {
                PostId = new Guid("9834d7b9-618d-435b-b86e-d9e861111738"),
                Value  = String.Empty
            };
            CommentValidator validator = new CommentValidator();

            validator.Validate(model);
        }
Exemple #5
0
        /// <summary>
        /// Method to validate model
        /// </summary>
        /// <returns>Returns the result of validation</returns>
        protected override FluentValidation.Results.ValidationResult Validate()
        {
            var validator = new CommentValidator();

            return(validator.Validate(this));
        }