-
-
Notifications
You must be signed in to change notification settings - Fork 424
/
Copy pathReflectTests.cs
122 lines (97 loc) · 2.78 KB
/
ReflectTests.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
namespace LanguageExt.Tests
{
public class ReflectTests
{
public class TestClass
{
public readonly string W;
public readonly string X;
public readonly string Y;
public readonly string Z;
public TestClass()
{
}
public TestClass(string w)
{
W = w;
}
public TestClass(string w, string x)
{
W = w;
X = x;
}
public TestClass(string w, bool x)
{
W = w;
X = x.ToString();
}
public TestClass(string w, string x, string y)
{
W = w;
X = x;
Y = y;
}
public TestClass(string w, string x, string y, string z)
{
W = w;
X = x;
Y = y;
Z = z;
}
}
[Fact]
public void CtorOfArity1Test()
{
var ctor = IL.Ctor<string, TestClass>();
var res = ctor("Hello");
Assert.True(res.W == "Hello");
}
[Fact]
public void CtorOfArity2Test()
{
var ctor = IL.Ctor<string, string, TestClass>();
var res = ctor("Hello", "World");
Assert.True(res.W == "Hello");
Assert.True(res.X == "World");
}
[Fact]
public void CtorOfArity2Test2()
{
var ctor = IL.Ctor<string, bool, TestClass>();
var res = ctor("Hello", true);
Assert.True(res.W == "Hello");
Assert.True(res.X == "True");
}
[Fact]
public void CtorOfArity3Test()
{
var ctor = IL.Ctor<string, string, string, TestClass>();
var res = ctor("Roland","TR", "909");
Assert.True(res.W == "Roland");
Assert.True(res.X == "TR");
Assert.True(res.Y == "909");
}
[Fact]
public void CtorOfArity4Test()
{
var ctor = IL.Ctor<string, string, string, string, TestClass>();
var res = ctor("Chandler", "Curve", "Bender", "EQ");
Assert.True(res.W == "Chandler");
Assert.True(res.X == "Curve");
Assert.True(res.Y == "Bender");
Assert.True(res.Z == "EQ");
}
[Fact]
public void DateConstructTest()
{
var ticks = new DateTime(2017, 1, 1).Ticks;
var ctor = IL.Ctor<long, DateTime>();
DateTime res = ctor(ticks);
Assert.True(res.Ticks == ticks);
}
}
}