public void SingleSource_OperatorPrecedence() { var target = new FilterFuncExpression(_BoolFilterFunc); var filterFunc1 = target.FromFilter("bool:false+bool:true,bool:true"); Assert.IsTrue(filterFunc1(null)); var filterFunc2 = target.FromFilter("bool:true,bool:true+bool:false"); Assert.IsTrue(filterFunc2(null)); }
public void SingleSource_NotOperator() { var target = new FilterFuncExpression(_BoolFilterFunc); var filterFunc = target.FromFilter("!bool:true"); Assert.IsFalse(filterFunc(null)); }
public void SingleSource() { Func <IIndexer, bool> expectedFunc1 = _ => throw TestExceptions.UnexpectedInvocation; Func <IIndexer, bool> expectedFunc2 = _ => throw TestExceptions.UnexpectedInvocation; var target = new FilterFuncExpression( new FilterFuncComponentStub("f1", _ => expectedFunc1), new FilterFuncComponentStub("f2", _ => expectedFunc2) ); var actualFunc1 = target.FromFilter("f1:args"); Assert.AreSame(expectedFunc1, actualFunc1); var actualFunc2 = target.FromFilter("f2:args"); Assert.AreSame(expectedFunc2, actualFunc2); var actualFunc3 = target.FromFilter("f3:args"); Assert.IsNull(actualFunc3); }
public static bool TryParse(string source, out Func <IIndexer, bool> func) { func = Expression.FromFilter(source); return(func != null); }