From c82f9646cd32c558e76265acc03629c32eeacd4b Mon Sep 17 00:00:00 2001 From: "Akins, Greg 76626" Date: Wed, 6 Jun 2018 10:47:53 -0400 Subject: [PATCH] #11 - Making method signature public --- .../ExpressionEvaluatorTests.cs | 16 +++++++++++++++ .../SimpleExpressionEvaluator.Tests.csproj | 3 +++ .../ExpressionEvaluator.cs | 20 ++++++++++++------- 3 files changed, 32 insertions(+), 7 deletions(-) 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 0dce56a..c2a89c0 100644 --- a/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj +++ b/SimpleExpressionEvaluator.Tests/SimpleExpressionEvaluator.Tests.csproj @@ -39,6 +39,9 @@ + + +