@@ -125,7 +125,7 @@ public void TypeTesting(string expression, Type type)
125125 [ TestCase ( "\" \\ n\" " , TestOf = typeof ( string ) , ExpectedResult = "\n " , Category = "StringEscape" ) ]
126126 [ TestCase ( "\" \\ r\" " , TestOf = typeof ( string ) , ExpectedResult = "\r " , Category = "StringEscape" ) ]
127127 [ TestCase ( "\" \\ t\" " , TestOf = typeof ( string ) , ExpectedResult = "\t " , Category = "StringEscape" ) ]
128- [ TestCase ( "\" " + @"\\" + "\" " , TestOf = typeof ( string ) , ExpectedResult = @"\" , Category = "StringEscape" ) ]
128+ [ TestCase ( "\" " + @"\\" + "\" " , TestOf = typeof ( string ) , ExpectedResult = @"\" , Category = "StringEscape" ) ]
129129 [ TestCase ( "\" " + @"\\\n" + "\" " , TestOf = typeof ( string ) , ExpectedResult = "\\ \n " , Category = "StringEscape" ) ]
130130 [ TestCase ( "@\" " + @"\\n" + "\" " , TestOf = typeof ( string ) , ExpectedResult = @"\\n" , Category = "StringEscape" ) ]
131131
@@ -135,7 +135,7 @@ public void TypeTesting(string expression, Type type)
135135 [ TestCase ( "$\" {{\" " , TestOf = typeof ( string ) , ExpectedResult = "{" , Category = "StringInterpolation" ) ]
136136 [ TestCase ( "$\" { \" {\" }\" " , TestOf = typeof ( string ) , ExpectedResult = "{" , Category = "StringInterpolation" ) ]
137137 [ TestCase ( "$\" Test { 5+5 } Test\" " , TestOf = typeof ( string ) , ExpectedResult = "Test 10 Test" , Category = "StringInterpolation" ) ]
138- [ TestCase ( "$\" Test { 5+5 + \" Test\" } Test\" " , TestOf = typeof ( string ) , ExpectedResult = "Test 10 Test Test" , Category = "StringInterpolation" ) ]
138+ [ TestCase ( "$\" Test { 5+5 + \" Test\" } Test\" " , TestOf = typeof ( string ) , ExpectedResult = "Test 10 Test Test" , Category = "StringInterpolation" ) ]
139139 [ TestCase ( "$\" Test { 5+5 + \" Test{\" } Test\" " , TestOf = typeof ( string ) , ExpectedResult = "Test 10 Test{ Test" , Category = "StringInterpolation" ) ]
140140 [ TestCase ( "$\" Test { 5+5 + \" Test{{ }\" } Test\" " , TestOf = typeof ( string ) , ExpectedResult = "Test 10 Test{{ } Test" , Category = "StringInterpolation" ) ]
141141
@@ -505,7 +505,7 @@ public void TypeTesting(string expression, Type type)
505505 [ TestCase ( "default(bool)" , TestOf = typeof ( bool ) , ExpectedResult = false , Category = "default values" ) ]
506506 [ TestCase ( "default(System.Boolean)" , TestOf = typeof ( bool ) , ExpectedResult = false , Category = "default values, Inline namespaces" ) ]
507507 #endregion
508-
508+
509509 #region typeof keyword
510510 [ TestCase ( "typeof(int)" , ExpectedResult = typeof ( int ) , Category = "typeof keyword" ) ]
511511 [ TestCase ( "typeof(float)" , ExpectedResult = typeof ( float ) , Category = "typeof keyword" ) ]
@@ -953,9 +953,9 @@ public void TypeTesting(string expression, Type type)
953953
954954 #region Generic types Management
955955
956- [ TestCase ( "List(\" Hello\" , \" Test\" ).Cast<string>().ToList<string>().GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "List function, Generics" ) ]
957- [ TestCase ( "new List<string>().GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "new Keyword, Generics" ) ]
958- [ TestCase ( "new Dictionary<string,List<int>>().GetType()" , ExpectedResult = typeof ( Dictionary < string , List < int > > ) , Category = "new Keyword, Generics" ) ]
956+ [ TestCase ( "List(\" Hello\" , \" Test\" ).Cast<string>().ToList<string>().GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "List function, Generics" ) ]
957+ [ TestCase ( "new List<string>().GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "new Keyword, Generics" ) ]
958+ [ TestCase ( "new Dictionary<string,List<int>>().GetType()" , ExpectedResult = typeof ( Dictionary < string , List < int > > ) , Category = "new Keyword, Generics" ) ]
959959
960960 #endregion
961961
@@ -1136,7 +1136,7 @@ public static IEnumerable<TestCaseData> TestCasesForWithCustomVariablesExpressio
11361136 #endregion
11371137
11381138 #region Delegates as Property of object
1139-
1139+
11401140 yield return new TestCaseData ( "customObject.AddAsDelegate(6, 10)" , onInstanceVariables , true ) . SetCategory ( "Delegate as a instance Property" ) . Returns ( 16 ) ;
11411141 yield return new TestCaseData ( "ClassForTest1.AddAsStaticDelegate(6, 10)" , onInstanceVariables , true ) . SetCategory ( "Delegate as a static Property" ) . Returns ( 16 ) ;
11421142
@@ -1167,7 +1167,7 @@ public object WithCustomVariablesExpressionEvaluation(string expression, Diction
11671167 [ TestCase ( "3.Add(2)" , ExpectedResult = 5 , Category = "On the fly method" ) ]
11681168 [ TestCase ( "3.MultipliedBy2" , ExpectedResult = 6 , Category = "On the fly property" ) ]
11691169 [ TestCase ( "myVar + 2" , ExpectedResult = 10 , Category = "On the fly variable" ) ]
1170- [ TestCase ( "SayHello(\" Bob\" )" , ExpectedResult = "Hello Bob" , Category = "On the fly variable " ) ]
1170+ [ TestCase ( "SayHello(\" Bob\" )" , ExpectedResult = "Hello Bob" , Category = "On the fly func " ) ]
11711171 #endregion
11721172 public object OnTheFlyEvaluation ( string expression )
11731173 {
@@ -1192,6 +1192,10 @@ private void Evaluator_EvaluateFunction(object sender, FunctionEvaluationEventAr
11921192 {
11931193 e . Value = $ "Hello { e . EvaluateArg ( 0 ) } ";
11941194 }
1195+ else if ( e . Name . Equals ( "GetSpecifiedGenericTypesFunc" ) )
1196+ {
1197+ e . Value = e . EvaluateGenericTypes ( ) ;
1198+ }
11951199 }
11961200
11971201 private void Evaluator_EvaluateVariable ( object sender , VariableEvaluationEventArg e )
@@ -1208,6 +1212,10 @@ private void Evaluator_EvaluateVariable(object sender, VariableEvaluationEventAr
12081212 {
12091213 e . Value = JsonConvert . SerializeObject ( e . This ) ;
12101214 }
1215+ else if ( e . Name . Equals ( "GetSpecifiedGenericTypesProp" ) )
1216+ {
1217+ e . Value = e . EvaluateGenericTypes ( ) ;
1218+ }
12111219 }
12121220
12131221 #endregion
@@ -1462,16 +1470,16 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
14621470 . SetCategory ( "Options" )
14631471 . SetCategory ( "Numbers Culture" ) ;
14641472
1465- yield return new TestCaseData ( new ExpressionEvaluator
1473+ yield return new TestCaseData ( new ExpressionEvaluator
14661474 {
14671475 OptionNumberParsingDecimalSeparator = "," ,
14681476 OptionNumberParsingThousandSeparator = "'" ,
14691477 OptionInitializersSeparator = ";"
14701478 }
1471- , "new double[]{1'200,5; 1'111'000,7}.Max()" )
1472- . Returns ( 1111000.7 )
1473- . SetCategory ( "Options" )
1474- . SetCategory ( "Numbers Culture" ) ;
1479+ , "new double[]{1'200,5; 1'111'000,7}.Max()" )
1480+ . Returns ( 1111000.7 )
1481+ . SetCategory ( "Options" )
1482+ . SetCategory ( "Numbers Culture" ) ;
14751483
14761484 #endregion
14771485
@@ -1485,9 +1493,9 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
14851493
14861494
14871495 yield return new TestCaseData ( new ExpressionEvaluator
1488- {
1489- OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = false
1490- }
1496+ {
1497+ OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = false
1498+ }
14911499 , "(130-120)/(2*250)" )
14921500 . Returns ( 0 )
14931501 . SetCategory ( "Options" )
@@ -1510,7 +1518,7 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
15101518 . SetCategory ( "Bug" )
15111519 . SetCategory ( "Options" )
15121520 . SetCategory ( "Integer Numbers default types" ) ;
1513-
1521+
15141522 yield return new TestCaseData ( evaluatorWithIntForceToDouble
15151523 , "Round(5.54,1, MidpointRounding.ToEven)" )
15161524 . Returns ( 5.5 )
@@ -1533,6 +1541,49 @@ public static IEnumerable<TestCaseData> TestCasesEvaluateWithSpecificEvaluator
15331541 . SetCategory ( "Integer Numbers default types" ) ;
15341542
15351543 #endregion
1544+
1545+ #region GenericTypes in onthefly events
1546+
1547+ ExpressionEvaluator evaluatorOnTheFlyGenericTypes = new ExpressionEvaluator ( ) ;
1548+
1549+ void VariableEval ( object sender , VariableEvaluationEventArg e )
1550+ {
1551+ e . Value = e . EvaluateGenericTypes ( ) ;
1552+ }
1553+
1554+ void FunctionEval ( object sender , FunctionEvaluationEventArg e )
1555+ {
1556+ e . Value = e . EvaluateGenericTypes ( ) ;
1557+ }
1558+
1559+ evaluatorOnTheFlyGenericTypes . EvaluateVariable += VariableEval ;
1560+ evaluatorOnTheFlyGenericTypes . EvaluateFunction += FunctionEval ;
1561+
1562+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1563+ , "GetSpecifiedGenericTypesFunc<string>()[0]" )
1564+ . Returns ( typeof ( string ) )
1565+ . SetCategory ( "On the fly func" )
1566+ . SetCategory ( "GenericTypes" ) ;
1567+
1568+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1569+ , "GetSpecifiedGenericTypesVar<string>[0]" )
1570+ . Returns ( typeof ( string ) )
1571+ . SetCategory ( "On the fly var" )
1572+ . SetCategory ( "GenericTypes" ) ;
1573+
1574+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1575+ , "GetSpecifiedGenericTypesFunc<string, List<int>>()[1]" )
1576+ . Returns ( typeof ( List < int > ) )
1577+ . SetCategory ( "On the fly func" )
1578+ . SetCategory ( "GenericTypes" ) ;
1579+
1580+ yield return new TestCaseData ( evaluatorOnTheFlyGenericTypes
1581+ , "GetSpecifiedGenericTypesFunc<string, List<int>>[1]" )
1582+ . Returns ( typeof ( List < int > ) )
1583+ . SetCategory ( "On the fly var" )
1584+ . SetCategory ( "GenericTypes" ) ;
1585+
1586+ #endregion
15361587 }
15371588 }
15381589
0 commit comments