Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just add simple test #398

Merged
merged 1 commit into from
Jul 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/MikArea/Dictionary.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using NFluent;
Expand Down Expand Up @@ -89,5 +90,25 @@ public void Test_ContainsKey_3()
Check.That("ZZZ1").IsEqualTo((string)data.First().City);
Check.That(3).IsEqualTo(data.Count);
}

[Fact]
public void Test_DynamicIndexCall()
{
{
object CreateDicParameter(string name) => new Dictionary<string, object>
{
{"Name", new Dictionary<string, object> {{"FirstName", name }, {"LastName", name + "Test" }}},
};

var parType = new Dictionary<string, object>().GetType();
var lambda = DynamicExpressionParser.ParseLambda(new[] { Expression.Parameter(parType, "item") }, typeof(object), "item.Name.FirstName + \"7\" + item.Name.LastName ").Compile();

var x1 = lambda.DynamicInvoke(CreateDicParameter("Julio"));
var x2 = lambda.DynamicInvoke(CreateDicParameter("John"));

Check.That(x1).IsEqualTo("Julio7JulioTest");
Check.That(x2).IsEqualTo("John7JohnTest");
}
}
}
}