public void IsInvalidIfAnyChildIsInvalid()
 {
     LogicCondition lc = new LogicCondition { Operator = "all" };
     var ec1 = new ExpressionCondition { LeftHandSide = "Person.Age", Operator = "is", RightHandSide = new List<string> { "18" } };
     var ec2 = new ExpressionCondition { LeftHandSide = "Whatever", Operator = "is", RightHandSide = new List<string> { "18" } };
     lc.AddCondition(ec1);
     lc.AddCondition(ec2);
     Assert.IsFalse(lc.IsValid(_context));
 }
 public void CanAddNestedLogicConditions()
 {
     LogicCondition lc1 = new LogicCondition { Operator = "any" };
     LogicCondition lc2 = new LogicCondition { Operator = "all" };
     var ec = new ExpressionCondition { LeftHandSide="Person.Age", Operator="is", RightHandSide=new List<string> { "18" } };
     lc1.AddCondition(ec);
     lc1.AddCondition(lc2);
     Assert.IsTrue(lc1.IsValid(_context));
 }
 public void IsInvalidIfDeeplyNestedChildIsInvalid()
 {
     LogicCondition lc1 = new LogicCondition { Operator = "all" };
     LogicCondition lc2 = new LogicCondition { Operator = "any" };
     LogicCondition lc3 = new LogicCondition { Operator = "any" };
     var ok = new ExpressionCondition { LeftHandSide = "Person.Age", Operator = "is", RightHandSide = new List<string> { "18" } };
     var bad = new ExpressionCondition { LeftHandSide = "Whatever", Operator = "is", RightHandSide = new List<string> { "18" } };
     lc1.AddCondition(ok);
     lc1.AddCondition(lc2);
     lc2.AddCondition(ok);
     lc1.AddCondition(lc3);
     lc3.AddCondition(bad);
     Assert.IsFalse(lc1.IsValid(_context));
 }
Esempio n. 4
0
 private static If CompileConditions(LogicCondition condition, Dictionary<string, Type> inputs)
 {
     var vbExpression = GetVBExpression(condition, inputs);
     var vbCondition = new VisualBasicValue<bool>(vbExpression);
     return new If(new InArgument<bool>(vbCondition));
 }
 public void EmptyConditionIsValid()
 {
     LogicCondition lc = new LogicCondition { Operator = "any" };
     Assert.IsTrue(lc.IsValid(_context));
 }