Beispiel #1
0
        public void TestValidate()
        {
            // No subnodes: Exception is thrown.
            TryInvalidValidate(new ExprLikeNode(true));

            // singe child node not possible, must be 2 at least
            _likeNodeNormal = new ExprLikeNode(false);
            _likeNodeNormal.AddChildNode(new SupportExprNode(4));
            TryInvalidValidate(_likeNodeNormal);

            // test a type mismatch
            _likeNodeNormal = new ExprLikeNode(true);
            _likeNodeNormal.AddChildNode(new SupportExprNode("sx"));
            _likeNodeNormal.AddChildNode(new SupportExprNode(4));
            TryInvalidValidate(_likeNodeNormal);

            // test numeric supported
            _likeNodeNormal = new ExprLikeNode(false);
            _likeNodeNormal.AddChildNode(new SupportExprNode(4));
            _likeNodeNormal.AddChildNode(new SupportExprNode("sx"));

            // test invalid escape char
            _likeNodeNormal = new ExprLikeNode(false);
            _likeNodeNormal.AddChildNode(new SupportExprNode(4));
            _likeNodeNormal.AddChildNode(new SupportExprNode("sx"));
            _likeNodeNormal.AddChildNode(new SupportExprNode(5));
        }
Beispiel #2
0
        public void TestEquals()
        {
            ExprLikeNode otherLikeNodeNot  = SupportExprNodeFactory.MakeLikeNode(true, "@");
            ExprLikeNode otherLikeNodeNot2 = SupportExprNodeFactory.MakeLikeNode(true, "!");

            Assert.IsTrue(_likeNodeNot.EqualsNode(otherLikeNodeNot2));
            Assert.IsTrue(otherLikeNodeNot2.EqualsNode(otherLikeNodeNot)); // Escape char itself is an expression
            Assert.IsFalse(_likeNodeNormal.EqualsNode(otherLikeNodeNot));
        }
Beispiel #3
0
 private void TryInvalidValidate(ExprLikeNode exprLikeRegexpNode)
 {
     try {
         exprLikeRegexpNode.Validate(ExprValidationContextFactory.MakeEmpty());
         Assert.Fail();
     }
     catch (ExprValidationException ex)
     {
         // expected
     }
 }
        public static ExprLikeNode MakeLikeNode(bool isNot, string optionalEscape)
        {
            // Build :      s0.string like "%abc__"  (with or witout escape)
            var node = new ExprLikeNode(isNot);

            node.AddChildNode(MakeIdentNode("TheString", "s0"));
            node.AddChildNode(new SupportExprNode("%abc__"));
            if (optionalEscape != null)
            {
                node.AddChildNode(new SupportExprNode(optionalEscape));
            }
            Validate3Stream(node);
            return(node);
        }
Beispiel #5
0
 public void SetUp()
 {
     _likeNodeNormal        = SupportExprNodeFactory.MakeLikeNode(false, null);
     _likeNodeNot           = SupportExprNodeFactory.MakeLikeNode(true, null);
     _likeNodeNormalEscaped = SupportExprNodeFactory.MakeLikeNode(false, "!");
 }