コード例 #1
0
 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));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 public void EmptyConditionIsValid()
 {
     LogicCondition lc = new LogicCondition { Operator = "any" };
     Assert.IsTrue(lc.IsValid(_context));
 }