public void ToPredicateTest() { ResultField rf = new ResultField(ResultFieldType.Measurement, "name", 100); Predicate<ResultField> p = (new ConditionBuilder()).LessThanConst(400) .Or() .OpenParenthesis() .GreaterThanConst(500) .And() .LessThanConst(1000) .And().Not() .EqualsConst(666) .CloseParenthesis() .ToPredicate(); Assert.IsTrue(p(ResultField.FillResult(rf, 399))); Assert.IsTrue(p(ResultField.FillResult(rf, 567))); Assert.IsFalse(p(ResultField.FillResult(rf, 400))); Assert.IsFalse(p(ResultField.FillResult(rf, 666))); Assert.IsFalse(p(ResultField.FillResult(rf, 1001))); Predicate<ResultField> p2 = (new ConditionBuilder()).EqualsConst(true).ToPredicate(); Assert.IsTrue(p2(new ResultField(ResultFieldType.Confirmation, "Is True", true))); Assert.IsFalse(p2(new ResultField(ResultFieldType.Confirmation, "Is False", false))); }
public void ToPredicateTest() { ResultField rf = new ResultField(ResultFieldType.Measurement, "name", 100); Predicate<ResultField> p = (new ConditionBuilder()).LessThanConst(400) .Or() .OpenParenthesis() .GreaterThanConst(500) .And() .LessThanConst(1000) .And().Not() .EqualsConst(666) .CloseParenthesis() .ToPredicate(); Assert.IsTrue(p(ResultField.FillResult(rf, 399))); Assert.IsTrue(p(ResultField.FillResult(rf, 567))); Assert.IsFalse(p(ResultField.FillResult(rf, 400))); Assert.IsFalse(p(ResultField.FillResult(rf, 666))); Assert.IsFalse(p(ResultField.FillResult(rf, 1001))); Predicate<ResultField> p2 = (new ConditionBuilder()).EqualsConst(true).ToPredicate(); Assert.IsTrue(p2(new ResultField(ResultFieldType.Confirmation, "Is True", true))); Assert.IsFalse(p2(new ResultField(ResultFieldType.Confirmation, "Is False", false))); }