public void fct_OP_10_Sep_bonjour_CP_retBool_true_ok() { ExpressionEval evaluator = new ExpressionEval(); // definir langue: fr ou en, sert pour les opérateurs: ET/AND, OU/OR, NON/NOT. evaluator.SetLang(Language.En); evaluator.SetStringTagCode(StringTagCode.Quote); string expr = "fct(10, 'bonjour')"; evaluator.Parse(expr); // link function body to function call evaluator.AttachFunction("Fct", FctP1Int_P2String); //====3/execute l'expression booléenne ExecResult execResult = evaluator.Exec(); Assert.AreEqual(false, execResult.HasError, "The exec of the expression should finish with success"); // check the final result value (is ExprExecFunctionCallBool override ExprExecValueBool) ExprExecValueBool valueBool = execResult.ExprExec as ExprExecValueBool; Assert.IsNotNull(execResult, "The result value should be a bool"); Assert.AreEqual(true, valueBool.Value, "The result value should be: true"); }
public void functionCall_paramTypeWrong_err() { ExpressionEval evaluator = new ExpressionEval(); // definir langue: fr ou en, sert pour les opérateurs: ET/AND, OU/OR, NON/NOT. evaluator.SetLang(Language.En); evaluator.SetStringTagCode(StringTagCode.Quote); string expr = "fct('bonjour')"; evaluator.Parse(expr); // link function body to function call evaluator.AttachFunction("Fct", FctInt); //====3/execute l'expression booléenne ExecResult execResult = evaluator.Exec(); Assert.IsTrue(execResult.HasError, "The exec of the expression should finish with error"); Assert.AreEqual(ErrorCode.FunctionCallParamTypeWrong, execResult.ListError[0].Code, "The exec of the expression should finish with error"); }