Skip to content

Commit fe321d1

Browse files
author
Sébastien Geiser
committed
Some tests for answer to issue #54
1 parent 628c19c commit fe321d1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,26 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
17581758
.Returns("Hello Bob")
17591759
.SetCategory("Context object");
17601760

1761+
ExpressionEvaluator evaluatorWithPersonContext = new ExpressionEvaluator();
1762+
1763+
evaluatorWithPersonContext.Context = new Person1()
1764+
{
1765+
Name = "John",
1766+
LastName = "Smith"
1767+
};
1768+
1769+
yield return new TestCaseData(evaluatorWithPersonContext
1770+
, "Name + \" \" + LastName"
1771+
, null)
1772+
.Returns("John Smith")
1773+
.SetCategory("Context object");
1774+
1775+
yield return new TestCaseData(evaluatorWithPersonContext
1776+
, "APersonMethod() + 10"
1777+
, null)
1778+
.Returns(20)
1779+
.SetCategory("Context object");
1780+
17611781
#endregion
17621782

17631783
#region inherits ExpressionEvaluator
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 Person1
4+
{
5+
public string Name { get; set; }
6+
public string LastName { get; set; }
7+
public int APersonMethod()
8+
{
9+
return 10;
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)