@@ -1399,6 +1399,20 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
13991399 yield return new TestCaseData ( evaluator , "new Regex(@\" \\ d+\" ).IsMatch(\" sdajflk32748safd\" )" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "Options" ) . SetCategory ( "TypesToBlock" ) ;
14001400
14011401 #endregion
1402+
1403+ #region On the fly pre events cancel
1404+
1405+ evaluator = new ExpressionEvaluator ( ) ;
1406+
1407+ evaluator . PreEvaluateVariable += ( sender , e ) =>
1408+ {
1409+ if ( e . Name . StartsWith ( "P" ) )
1410+ e . CancelEvaluation = true ;
1411+ } ;
1412+
1413+ yield return new TestCaseData ( evaluator , "Pi" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1414+
1415+ #endregion
14021416 }
14031417 }
14041418
@@ -1555,12 +1569,14 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
15551569
15561570 void VariableEval ( object sender , VariableEvaluationEventArg e )
15571571 {
1558- e . Value = e . EvaluateGenericTypes ( ) ;
1572+ if ( e . Name . Equals ( "GetSpecifiedGenericTypesVar" ) )
1573+ e . Value = e . EvaluateGenericTypes ( ) ;
15591574 }
15601575
15611576 void FunctionEval ( object sender , FunctionEvaluationEventArg e )
15621577 {
1563- e . Value = e . EvaluateGenericTypes ( ) ;
1578+ if ( e . Name . Equals ( "GetSpecifiedGenericTypesFunc" ) )
1579+ e . Value = e . EvaluateGenericTypes ( ) ;
15641580 }
15651581
15661582 void Evaluator_PreEvaluateFunction ( object sender , FunctionPreEvaluationEventArg e )
@@ -1585,7 +1601,7 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
15851601 else if ( e . Name . Equals ( "GenericAssembly" ) && e . HasGenericTypes )
15861602 {
15871603 // e.EvaluateGenericTypes() return a Type[]
1588- e . Value = e . EvaluateGenericTypes ( ) [ 0 ] . Assembly ;
1604+ e . Value = e . EvaluateGenericTypes ( ) [ 0 ] . Assembly . GetName ( ) . Name ;
15891605 }
15901606 }
15911607
@@ -1614,7 +1630,7 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
16141630 . SetCategory ( "GenericTypes" ) ;
16151631
16161632 yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1617- , "GetSpecifiedGenericTypesFunc <string, List<int>>[1]" )
1633+ , "GetSpecifiedGenericTypesVar <string, List<int>>[1]" )
16181634 . Returns ( typeof ( List < int > ) )
16191635 . SetCategory ( "On the fly var" )
16201636 . SetCategory ( "GenericTypes" ) ;
@@ -1627,8 +1643,8 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
16271643
16281644 yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
16291645 , "GenericAssembly<string>" )
1630- . Returns ( "System.Collections.Generic " )
1631- . SetCategory ( "On the fly func " )
1646+ . Returns ( "mscorlib " )
1647+ . SetCategory ( "On the fly var " )
16321648 . SetCategory ( "GenericTypes" ) ;
16331649
16341650 #endregion
0 commit comments