diff --git a/SimpleExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs b/SimpleExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs index 709dd27..bec7c7b 100644 --- a/SimpleExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs +++ b/SimpleExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Threading; using NUnit.Framework; @@ -125,6 +126,21 @@ public void Can_Pass_Named_Variables() Assert.That(dynamicEngine.Evaluate("(c+b)*a", a: 6, b: 4.5, c: 2.6), Is.EqualTo((c + b) * a)); } + [Test] + public void Can_Pass_A_Dictionary() + { + dynamic dynamicEngine = new ExpressionEvaluator(); + + var a = 6; + var b = 4.5m; + var c = 2.6m; + Dictionary dict = new Dictionary(); + dict.Add("a", a); + dict.Add("b", b); + dict.Add("c", c); + + Assert.That(dynamicEngine.Evaluate("(c+b)*a", dict), Is.EqualTo((c + b) * a)); + } [Test] public void Can_Invoke_Expression_Multiple_Times() diff --git a/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj b/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj index 328bcba..218dc1d 100644 --- a/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj +++ b/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj @@ -39,6 +39,9 @@ + + +