Skip to content

Commit 628c19c

Browse files
author
Sébastien Geiser
committed
First implementation of Context object + first corresponding tests
1 parent c7fc80a commit 628c19c

File tree

3 files changed

+131
-100
lines changed

3 files changed

+131
-100
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,24 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
17421742

17431743
#endregion
17441744

1745+
#region with Context object
1746+
1747+
ExpressionEvaluator evaluatorWithContext = new ExpressionEvaluator(new ContextObject1());
1748+
1749+
yield return new TestCaseData(evaluatorWithContext
1750+
, "AIntValue"
1751+
, null)
1752+
.Returns(3)
1753+
.SetCategory("Context object");
1754+
1755+
yield return new TestCaseData(evaluatorWithContext
1756+
, "SayHelloTo(\"Bob\")"
1757+
, null)
1758+
.Returns("Hello Bob")
1759+
.SetCategory("Context object");
1760+
1761+
#endregion
1762+
17451763
#region inherits ExpressionEvaluator
17461764

17471765
#region Redefine existing operators
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace CodingSeb.ExpressionEvaluator.Tests
2+
{
3+
public class ContextObject1
4+
{
5+
public int AIntValue { get; set; } = 3;
6+
7+
public string SayHelloTo(string name)
8+
{
9+
return "Hello " + name;
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)