Exemple #1
0
        public void AttributeValuePatternConstraintTest()
        {
            Excel.MdxTuple    mdxTuple = new Excel.MdxTuple();
            ValidationContext context  = new ValidationContext()
            {
                Element = mdxTuple
            };

            AttributeValuePatternConstraint constraint = new AttributeValuePatternConstraint()
            {
                AttributeLocalName = "bc",
                AttributeNamespace = "",
                Pattern            = "^0x00[0-9]{6,6}$"
            };

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

            mdxTuple.BackgroundColor = null;
            Assert.Null(constraint.Validate(context));

            mdxTuple.BackgroundColor = "";
            Assert.Null(constraint.Validate(context));

            mdxTuple.BackgroundColor = "0x12345678";
            Assert.NotNull(constraint.Validate(context));

            mdxTuple.BackgroundColor = "0x00123456";
            Assert.Null(constraint.Validate(context));
        }
        public void AttributeValuePatternConstraintTest()
        {
            Excel.MdxTuple mdxTuple = new Excel.MdxTuple();
            ValidationContext context = new ValidationContext() { Element = mdxTuple };

            AttributeValuePatternConstraint constraint = new AttributeValuePatternConstraint()
            {
                AttributeLocalName = "bc",
                AttributeNamespace = "",
                Pattern = "^0x00[0-9]{6,6}$"
            };

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

            mdxTuple.BackgroundColor = null;
            Assert.Null(constraint.Validate(context));

            mdxTuple.BackgroundColor = "";
            Assert.Null(constraint.Validate(context));

            mdxTuple.BackgroundColor = "0x12345678";
            Assert.NotNull(constraint.Validate(context));

            mdxTuple.BackgroundColor = "0x00123456";
            Assert.Null(constraint.Validate(context));
        }