@@ -1402,15 +1402,29 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
14021402
14031403 #region On the fly pre events cancel
14041404
1405- evaluator = new ExpressionEvaluator ( ) ;
1405+ evaluator = new ExpressionEvaluator ( new Dictionary < string , object >
1406+ {
1407+ { "P1var" , "P1" } ,
1408+ { "myObj" , new ClassForTest1 ( ) } ,
1409+ } ) ;
14061410
14071411 evaluator . PreEvaluateVariable += ( sender , e ) =>
14081412 {
14091413 if ( e . Name . StartsWith ( "P" ) )
14101414 e . CancelEvaluation = true ;
14111415 } ;
14121416
1417+ evaluator . PreEvaluateFunction += ( sender , e ) =>
1418+ {
1419+ if ( e . Name . StartsWith ( "A" ) )
1420+ e . CancelEvaluation = true ;
1421+ } ;
1422+
14131423 yield return new TestCaseData ( evaluator , "Pi" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1424+ yield return new TestCaseData ( evaluator , "P1var" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1425+ yield return new TestCaseData ( evaluator , "myObj.PropertyThatWillFailed" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1426+ yield return new TestCaseData ( evaluator , "myObj.Add3To(5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
1427+ yield return new TestCaseData ( evaluator , "Abs(-5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
14141428
14151429 #endregion
14161430 }
@@ -1563,14 +1577,20 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
15631577
15641578 #endregion
15651579
1566- #region Onthefly events (Pre events and/or Generics)
1580+ #region Onthefly events (Pre events custom vars and standard events priorities and/or Generics)
15671581
1568- ExpressionEvaluator evaluatorOnTheFlyGenericTypes = new ExpressionEvaluator ( ) ;
1582+ ExpressionEvaluator evaluatorOnTheFlyGenericTypes = new ExpressionEvaluator ( new Dictionary < string , object >
1583+ {
1584+ { "myvar1" , 10 } ,
1585+ { "myvar2" , 3 } ,
1586+ } ) ;
15691587
15701588 void VariableEval ( object sender , VariableEvaluationEventArg e )
15711589 {
1572- if ( e . Name . Equals ( "GetSpecifiedGenericTypesVar" ) )
1590+ if ( e . Name . Equals ( "GetSpecifiedGenericTypesVar" ) )
15731591 e . Value = e . EvaluateGenericTypes ( ) ;
1592+ else if ( e . Name . Equals ( "myvar2" ) )
1593+ e . Value = 50 ;
15741594 }
15751595
15761596 void FunctionEval ( object sender , FunctionEvaluationEventArg e )
@@ -1647,6 +1667,16 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
16471667 . SetCategory ( "On the fly var" )
16481668 . SetCategory ( "GenericTypes" ) ;
16491669
1670+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1671+ , "myvar1" )
1672+ . Returns ( 5 )
1673+ . SetCategory ( "var evaluation priority" ) ;
1674+
1675+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1676+ , "myvar2" )
1677+ . Returns ( 3 )
1678+ . SetCategory ( "var evaluation priority" ) ;
1679+
16501680 #endregion
16511681 }
16521682 }
0 commit comments