Skip to content

Commit

Permalink
Added Missing Using Statements
Browse files Browse the repository at this point in the history
Switched to string.Concat because Path.Combine changes might differ per OS
  • Loading branch information
Pentiva committed Sep 21, 2023
1 parent 87182e7 commit 8746c32
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/DynamicExpresso.UnitTest/GithubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Dynamic;

// ReSharper disable SpecifyACultureInStringConversionExplicitly

Expand Down Expand Up @@ -778,18 +779,18 @@ public void GitHub_Issue_295() {
var evaluator = new Interpreter();

// create path helper functions in expressions...
Func<string, string, string> pathCombine = Path.Combine;
evaluator.SetFunction("PathCombine", pathCombine);
Func<string, string, string> pathCombine = string.Concat;
evaluator.SetFunction("StringConcat", pathCombine);

// add a GlobalSettings dynamic object...
dynamic globalSettings = new ExpandoObject();
globalSettings.MyTestPath = "C:\\delme\\";
evaluator.SetVariable("GlobalSettings", globalSettings);

var works = (string) evaluator.Eval("PathCombine((string)GlobalSettings.MyTestPath,\"test.txt\")");
var works = (string) evaluator.Eval("StringConcat((string)GlobalSettings.MyTestPath,\"test.txt\")");
Assert.That(works, Is.EqualTo("C:\\delme\\test.txt"));

var doesntWork = (string) evaluator.Eval("PathCombine(GlobalSettings.MyTestPath,\"test.txt\")");
var doesntWork = (string) evaluator.Eval("StringConcat(GlobalSettings.MyTestPath,\"test.txt\")");
Assert.That(doesntWork, Is.EqualTo("C:\\delme\\test.txt"));
}
}
Expand Down

0 comments on commit 8746c32

Please sign in to comment.