forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinderHelperTest.cs
More file actions
56 lines (50 loc) · 2.05 KB
/
BinderHelperTest.cs
File metadata and controls
56 lines (50 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using Simple.Data.Extensions;
using NUnit.Framework;
namespace Simple.Data.UnitTest
{
[TestFixture]
public class BinderHelperTest
{
[Test]
public void NamedArgumentsToDictionaryShouldApplyNamesToLastArguments()
{
var binder = new TestInvokeMemberBinder("Test", false, new CallInfo(2, "Foo"));
var actual = binder.NamedArgumentsToDictionary(new object[] {1, 2});
Assert.AreEqual(2, actual["Foo"]);
}
[Test]
public void ArgumentsToDictionaryShouldApplyOrdinalNamesToFirstArguments()
{
var binder = new TestInvokeMemberBinder("Test", false, new CallInfo(2, "Foo"));
var actual = binder.ArgumentsToDictionary(new object[] { 1, 2 });
Assert.AreEqual("_0", actual.First().Key);
}
[Test]
public void ArgumentsToDictionaryShouldReturnInputParameterWhenInputParameterIsDictionary()
{
var binder = new TestInvokeMemberBinder("Test", false, new CallInfo(1, "Foo"));
var input = new Dictionary<string, object> { { "Test1", 1 }, { "Test2", 2 } };
var actual = binder.ArgumentsToDictionary(new object[] { input });
Assert.AreEqual(input["Test2"], actual["Test2"]);
}
}
class TestInvokeMemberBinder : InvokeMemberBinder
{
public TestInvokeMemberBinder(string name, bool ignoreCase, CallInfo callInfo) : base(name, ignoreCase, callInfo)
{
}
public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
{
throw new NotImplementedException();
}
public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
{
throw new NotImplementedException();
}
}
}