-
Notifications
You must be signed in to change notification settings - Fork 44
/
TuplerTest.cs
157 lines (124 loc) · 4.46 KB
/
TuplerTest.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dynamitey;
using NUnit.Framework;
namespace Dynamitey.Tests
{
[TestFixture]
public class TuplerTest
{
[Test]
public void DynamicCreateTypedTuple()
{
object tup = Tupler.Create(1, "2", "3", 4);
var tup2 = Tuple.Create(1, "2", "3", 4);
Assert.That(tup, Is.TypeOf(tup2.GetType()));
Assert.That(tup, Is.EqualTo(tup2));
}
[Test]
public void DynamicCreateTypedTuple8()
{
object tup = Tupler.Create(1, "2", "3", 4,
5, 6, 7, "8");
var tup2 = Tuple.Create(1, "2", "3", 4, 5, 6, 7, "8");
Assert.That(tup,Is.TypeOf(tup2.GetType()));
Assert.That(tup, Is.EqualTo(tup2));
}
[Test]
public void DynamicCreateLongTypedTuple()
{
object tup = Tupler.Create(1, "2", "3", 4,
5, 6, 7, "8", "9", 10, "11", 12);
var tup2 = new Tuple<int, string, string, int, int, int, int, Tuple<string, string, int, string, int>>(
1, "2", "3", 4,
5, 6, 7, Tuple.Create("8", "9", 10, "11", 12)
);
Assert.That(tup, Is.TypeOf(tup2.GetType()));
Assert.That(tup, Is.EqualTo(tup2));
}
[Test]
public void DynamicTupleSize()
{
var tup = Tuple.Create(1, 2, 3, 4, 5);
Assert.That((object)Tupler.Size(tup),Is.EqualTo(5));
}
[Test]
public void DynamicTupleSize8()
{
var tup = Tuple.Create(1, 2, 3, 4, 5,6,7,8);
Assert.That((object)Tupler.Size(tup), Is.EqualTo(8));
}
[Test]
public void DynamicTupleSize20()
{
var tup = Tupler.Create(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
Assert.That((object)Tupler.Size(tup), Is.EqualTo(20));
}
[Test]
public void DynamicTupleToList()
{
var tup =Tuple.Create(1, 2, 3, 4, 5);
var exp=Enumerable.Range(1,5).ToList();
Assert.That((object)Tupler.ToList(tup),Is.EqualTo(exp));
}
[Test]
public void DynamicTupleToList8()
{
var tup = Tuple.Create(1, 2, 3, 4, 5, 6, 7, 8);
var exp = Enumerable.Range(1, 8).ToList();
Assert.That((object)Tupler.ToList(tup), Is.EqualTo(exp));
}
[Test]
public void DynamicTupleToList20()
{
var tup = Tupler.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
var exp = Enumerable.Range(1, 20).ToList();
Assert.That((object)Tupler.ToList(tup), Is.EqualTo(exp));
}
[Test]
public void DynamicListToTuple()
{
var exp = Enumerable.Range(1, 5).ToList();
var tup = exp.ToTuple();
Assert.That((object)Tupler.IsTuple(tup), Is.True);
Assert.That((object)Tupler.ToList(tup), Is.EqualTo(exp));
}
[Test]
public void DynamicListToTuplet8()
{
var exp = Enumerable.Range(1, 8).ToList();
var tup = exp.ToTuple();
Assert.That((object)Tupler.IsTuple(tup), Is.True);
Assert.That((object)Tupler.ToList(tup), Is.EqualTo(exp));
}
[Test]
public void DynamicListToTuple20()
{
var exp = Enumerable.Range(1, 20).ToList();
var tup = exp.ToTuple();
Assert.That((object)Tupler.IsTuple(tup), Is.True);
Assert.That((object)Tupler.ToList(tup), Is.EqualTo(exp));
}
[Test]
public void DynamicTupleIndex()
{
var tup = Tupler.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
Assert.That((object)Tupler.Index(tup,5), Is.EqualTo(6));
}
[Test]
public void DynamicTupleIndex7()
{
var tup = Tupler.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
Assert.That((object)Tupler.Index(tup, 7), Is.EqualTo(8));
}
[Test]
public void DynamicTupleIndex19()
{
var tup = Tupler.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
Assert.That((object)Tupler.Index(tup, 19), Is.EqualTo(20));
}
}
}