public void WhenTextInputLineHasDoubleHyphen_ThenFailsValidation()
        {
            var validator = new TextLineInputValidatorAttribute();

            Assert.Throws <ValidationException>(
                () => validator.Validate("AB--C", "TestName"));
        }
        public void WhenTextInputLineHasInvalidCharacters_ThenFailsValidation()
        {
            var validator = new TextLineInputValidatorAttribute();

            Assert.Throws <ValidationException>(
                () => validator.Validate("AB<>C", "TestName"));
        }
        public void WhenTextInputLineHasMultipleLines_ThenFailsValidation()
        {
            var validator = new TextLineInputValidatorAttribute();

            Assert.Throws <ValidationException>(
                () => validator.Validate("ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz", "TestName"));
        }
        public void WhenGetClientValidationRules_ThenReturnsValidationRule()
        {
            var validationRules = new TextLineInputValidatorAttribute().GetClientValidationRules(null, null).ToList();

            Assert.Equal(1, validationRules.Count());
            Assert.Equal("textlineinput", validationRules[0].ValidationType);
            Assert.Equal("Only alpha-numeric characters and [.,_-'] are allowed.", validationRules[0].ErrorMessage);
            Assert.Equal(1, validationRules[0].ValidationParameters.Count);
            Assert.Equal(@"^(?!.*--)[A-Za-z0-9\.,'_ \-]*$", validationRules[0].ValidationParameters["pattern"]);
        }
        public void WhenCreated_ThenImplementsIClientValidatable()
        {
            var validator = new TextLineInputValidatorAttribute();

            Assert.IsAssignableFrom <IClientValidatable>(validator);
        }
        public void WhenTextInputLineHasValidCharacters_ThenPassesValidation()
        {
            var validator = new TextLineInputValidatorAttribute();

            validator.Validate(@"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz_'-,.", "TestName");
        }