예제 #1
0
 public void SimplestExpression()
 {
     var expr = "permission.name";
     var p = new Parser(expr);
     ExpressionToken t = p.Parse();
     Assert.IsInstanceOfType(typeof(PermissionExpressionToken), t);
     Assert.AreEqual(expr, ((PermissionExpressionToken)t).PermissionName);
 }
예제 #2
0
 public void SimpleOrExpression()
 {
     var expr = "p.1 | p.2";
     var p = new Parser(expr);
     var root = (OperatorExpressionToken)p.Parse();
     Assert.AreEqual(Operator.Or, root.Operator);
     var lhs = root.Left;
     var rhs = (PermissionExpressionToken)root.Right;
     Assert.AreEqual("p.1", lhs.PermissionName);
     Assert.AreEqual("p.2", rhs.PermissionName);
 }
예제 #3
0
        public void DoubleAndExpression()
        {
            var expr = "p.1 & p.2 & p.3";
            var p = new Parser(expr);
            var root = (OperatorExpressionToken)p.Parse();
            Assert.AreEqual(Operator.And, root.Operator);
            var firstPermission = root.Left;
            var secondExpression = (OperatorExpressionToken)root.Right;
            Assert.AreEqual("p.1", firstPermission.PermissionName);

            Assert.AreEqual(Operator.And, secondExpression.Operator);
            Assert.AreEqual("p.2", secondExpression.Left.PermissionName);
            Assert.AreEqual("p.3", ((PermissionExpressionToken)secondExpression.Right).PermissionName);
        }