GenericCallUtilityTests.cs
1.34 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
57
58
59
60
using UnityEngine;
using NUnit.Framework;
using System.Collections;
using System;
namespace UniJSON
{
public class GenericCallUtilityTests
{
class Sample
{
public int Value
{
get;
private set;
}
public void Set(int value)
{
Value = value;
}
public int Get(int _)
{
return Value;
}
}
[Test]
public void GenericCallUtilityTestsSimplePasses()
{
var s = new Sample();
{
var mi = s.GetType().GetMethod("Set");
var action = GenericInvokeCallFactory.OpenAction<Sample, int>(mi);
action(s, 1);
Assert.AreEqual(1, s.Value);
}
{
var mi = s.GetType().GetMethod("Get");
var func = GenericInvokeCallFactory.OpenFunc<Sample, int, int>(mi);
/*var value =*/ func(s, 1);
Assert.AreEqual(1, s.Value);
}
{
var mi = s.GetType().GetMethod("Set");
var action = GenericExpressionCallFactory.Create<Sample, int>(mi);
action(s, 2);
Assert.AreEqual(2, s.Value);
}
}
}
}