File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
CodingSeb.ExpressionEvaluator.Tests Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1641,6 +1641,43 @@ public void Evaluate_ParameterTypeMismatchAutoAdapt()
1641
1641
. ShouldBeOfType < DateTime > ( ) ;
1642
1642
}
1643
1643
1644
+ /// <summary>
1645
+ /// To correct #104 Extension methods do not work on context
1646
+ /// </summary>
1647
+ [ Test ]
1648
+ [ Category ( "Bug" ) ]
1649
+ [ Category ( "#104" ) ]
1650
+ public void Evaluate_ExtensionMethodOnContext ( )
1651
+ {
1652
+ var evaluator = new ExpressionEvaluator
1653
+ {
1654
+ Context = new List < int > ( )
1655
+ {
1656
+ 1 , 2 , 3 , 4 , 5
1657
+ }
1658
+ } ;
1659
+
1660
+ evaluator . Evaluate ( "Sum()" )
1661
+ . ShouldBe ( 15 ) ;
1662
+ }
1663
+
1664
+ /// <summary>
1665
+ /// To correct #105 Exception should be thrown and not set in the stack
1666
+ /// </summary>
1667
+ [ Test ]
1668
+ [ Category ( "Bug" ) ]
1669
+ [ Category ( "#105" ) ]
1670
+ public void Evaluate_Exceptions_NotThrown ( )
1671
+ {
1672
+ var evaluator = new ExpressionEvaluator
1673
+ {
1674
+ Context = new { Person = new Person2 { Name = null , Number = 1.11m } }
1675
+ } ;
1676
+
1677
+ Should . Throw < Exception > ( ( ) => Console . WriteLine ( evaluator . Evaluate ( "\" Test one \" + Person.Name.Trim()" ) ) ) ;
1678
+ Should . Throw < Exception > ( ( ) => Console . WriteLine ( evaluator . Evaluate ( "\" Test two \" + Person.AnotherName.Trim()" ) ) ) ;
1679
+ }
1680
+
1644
1681
#endregion
1645
1682
1646
1683
#region EvaluateWithSpecificEvaluator
You can’t perform that action at this time.
0 commit comments