Example #1
0
        public void AttributeValueLengthConstraintTest()
        {
            Word.DecimalSymbol decimalSymbol = new Word.DecimalSymbol();
            ValidationContext  context       = new ValidationContext()
            {
                Element = decimalSymbol
            };

            AttributeValueLengthConstraint constraint = new AttributeValueLengthConstraint()
            {
                AttributeLocalName = "val",
                AttributeNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
                MinLength          = 1,
                MaxLength          = 1
            };

            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = null;
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = "";
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = ",";
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = "!~";
            Assert.NotNull(constraint.Validate(context));
        }
        public void AttributeValueLengthConstraintTest()
        {
            Word.DecimalSymbol decimalSymbol = new Word.DecimalSymbol();
            ValidationContext context = new ValidationContext() { Element = decimalSymbol };

            AttributeValueLengthConstraint constraint = new AttributeValueLengthConstraint()
            {
                AttributeLocalName = "val",
                AttributeNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
                MinLength = 1,
                MaxLength = 1
            };

            Assert.Null(constraint.Validate(context));
            
            decimalSymbol.Val = null;
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = "";
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = ",";
            Assert.Null(constraint.Validate(context));

            decimalSymbol.Val = "!~";
            Assert.NotNull(constraint.Validate(context));
        }