Exemplo n.º 1
0
        public void TestTextCheckRestrictedSymbols()
        {
            const string AllChars = "abcdefghijklmnopqrstuvwxyz \n\t абвгдеёжзийклмнопрстуфхцчшщьыъэюя 1234567890 \\ \" .,;:~'`!? №@#$%^&_ []{}()<> /*-+=";
            var          value    = new TextElementValue {
                Raw = AllChars
            };
            var constraints = new PlainTextElementConstraints();

            var errorSpace = TestHelpers.MakeValidationCheck <TextElementValue, NonBreakingSpaceSymbolError>(
                value,
                constraints,
                PlainTextValidator.CheckRestrictedSymbols,
                val => val.Raw = "\x00A0");

            Assert.Equal(nameof(constraints.WithoutNonBreakingSpace), errorSpace.ErrorType);

            value.Raw = AllChars.ToUpper();
            var errorControlChars = TestHelpers.MakeValidationCheck <TextElementValue, ControlCharactersInTextError>(
                value,
                constraints,
                PlainTextValidator.CheckRestrictedSymbols,
                val => val.Raw = "\r");

            Assert.Equal(nameof(constraints.WithoutControlChars), errorControlChars.ErrorType);
        }
Exemplo n.º 2
0
        public void TestFasCommentCheckRestrictedSymbols()
        {
            const string AllChars = "abcdefghijklmnopqrstuvwxyz \n\t абвгдеёжзийклмнопрстуфхцчшщьыъэюя 1234567890 \\ \" .,;:~'`!? №@#$%^&|_ []{}()<> /*-+=";
            var          value    = new FasElementValue {
                Raw = "custom", Text = AllChars
            };
            var constraints = new PlainTextElementConstraints();

            TestHelpers.MakeValidationCheck <FasElementValue, NonBreakingSpaceSymbolError>(value, constraints, PlainTextValidator.CheckRestrictedSymbols, val => val.Text = "\x00A0");

            value.Text = AllChars.ToUpper();
            TestHelpers.MakeValidationCheck <FasElementValue, ControlCharactersInTextError>(value, constraints, PlainTextValidator.CheckRestrictedSymbols, val => val.Text = "\r");
        }