Beispiel #1
0
        public CommentValidationResult Validate(Comment comment, NameValueCollection form)
        {
            var args = new ValidateCommentArgs(comment, form);

            CorePipelineManager.Run("weblogValidateComment", args, true);

            return(new CommentValidationResult(args.Errors));
        }
Beispiel #2
0
        public void Ctor_ValidParameters_SetsProperties()
        {
            // arrange
            var comment = new Comment();
            var form    = new NameValueCollection();

            // act
            var sut = new ValidateCommentArgs(comment, form);

            // assert
            Assert.That(sut.Comment, Is.SameAs(comment));
            Assert.That(sut.Form, Is.SameAs(form));
        }
        public void Process_ContactIsHuman_NoErrorsInArgs()
        {
            // arrange
            var args = new ValidateCommentArgs(new Comment(), new NameValueCollection());
            var sut  = new ContactNotRobot();

            var tracker = CreateTracker(ContactClassification.Unidentified);

            // act
            using (new TrackerSwitcher(tracker))
            {
                sut.Process(args);
            }

            // assert
            Assert.That(args.Errors, Is.Empty);
        }
Beispiel #4
0
        public void Process_NameIsValid_NoErrorsInArgs()
        {
            // arrange
            var comment = new Comment
            {
                AuthorEmail = "*****@*****.**",
                Text        = "comment",
                AuthorName  = "name"
            };

            var args = new ValidateCommentArgs(comment, new NameValueCollection());
            var sut  = new NameProvided();

            // act
            sut.Process(args);

            // assert
            Assert.That(args.Errors, Is.Empty);
        }
        public void Process_ContactIsRobot_AddsErrorToArgs()
        {
            // arrange
            var args = new ValidateCommentArgs(new Comment(), new NameValueCollection());
            var sut  = new ContactNotRobot();

            var tracker = CreateTracker(ContactClassification.RobotBoundary);

            // act
            using (new TrackerSwitcher(tracker))
            {
                sut.Process(args);
            }

            // assert
            var errorText = args.Errors.First();

            Assert.That(errorText, Is.EqualTo("An error occurred. Please try again later."));
        }
Beispiel #6
0
        public void Process_NameIsInvalid_AddsErrorToArgs(string name)
        {
            // arrange
            var comment = new Comment
            {
                AuthorEmail = "*****@*****.**",
                Text        = "comment",
                AuthorName  = name
            };

            var args = new ValidateCommentArgs(comment, new NameValueCollection());
            var sut  = new NameProvided();

            // act
            sut.Process(args);

            // assert
            var errorText = args.Errors.First();

            Assert.That(errorText, Is.EqualTo("Required field Name is missing."));
        }