forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroupingHandlerTest.cs
48 lines (47 loc) · 2.35 KB
/
GroupingHandlerTest.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Simple.Data.QueryPolyfills;
namespace Simple.Data.UnitTest
{
[TestFixture]
class GroupingHandlerTest
{
[Test]
public void GroupingOnSingleKeyWorks()
{
var source = new List<IDictionary<string, object>>
{
new Dictionary<string, object> {{"Id", 1}, {"Size", 1}},
new Dictionary<string, object> {{"Id", 1}, {"Size", 2}},
new Dictionary<string, object> {{"Id", 1}, {"Size", 3}},
new Dictionary<string, object> {{"Id", 2}, {"Size", 4}},
new Dictionary<string, object> {{"Id", 2}, {"Size", 5}},
new Dictionary<string, object> {{"Id", 2}, {"Size", 6}},
};
var target = new GroupingHandler("Id");
var actual = target.Group(source).ToList();
Assert.AreEqual(2, actual.Count);
}
[Test]
public void GroupingOnDoubleKeyWorks()
{
var source = new List<IDictionary<string, object>>
{
new Dictionary<string, object> {{"Id", 1}, {"Type", "A"}, {"Size", 1}},
new Dictionary<string, object> {{"Id", 1}, {"Type", "A"}, {"Size", 2}},
new Dictionary<string, object> {{"Id", 1}, {"Type", "B"}, {"Size", 3}},
new Dictionary<string, object> {{"Id", 1}, {"Type", "B"}, {"Size", 4}},
new Dictionary<string, object> {{"Id", 2}, {"Type", "A"}, {"Size", 5}},
new Dictionary<string, object> {{"Id", 2}, {"Type", "A"}, {"Size", 6}},
new Dictionary<string, object> {{"Id", 2}, {"Type", "B"}, {"Size", 7}},
new Dictionary<string, object> {{"Id", 2}, {"Type", "B"}, {"Size", 8}},
};
var target = new GroupingHandler("Id", "Type");
var actual = target.Group(source).ToList();
Assert.AreEqual(4, actual.Count);
}
}
}