forked from dncuug/X.PagedList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplitAndPartitionFacts.cs
67 lines (55 loc) · 1.38 KB
/
SplitAndPartitionFacts.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
using System.Linq;
using Xunit;
namespace X.PagedList.Tests
{
public class SplitAndPartitionFacts
{
[Fact]
public void Partition_Works()
{
//arrange
var list = Enumerable.Range(1, 9999);
//act
var partitionList = list.Partition(1000);
//assert
Assert.Equal(10, partitionList.Count());
Assert.Equal(1000, partitionList.First().Count());
Assert.Equal(999, partitionList.Last().Count());
}
[Fact]
public void Partition_Returns_Enumerable_With_One_Item_When_Count_Less_Than_Page_Size()
{
//arrange
var list = Enumerable.Range(1,10);
//act
var partitionList = list.Partition(1000);
//assert
Assert.Equal(1, partitionList.Count());
Assert.Equal(10, partitionList.First().Count());
}
[Fact]
public void Split_Works()
{
//arrange
var list = Enumerable.Range(1, 9999);
//act
var splitList = list.Split(10);
//assert
Assert.Equal(10, splitList.Count());
Assert.Equal(1000, splitList.First().Count());
Assert.Equal(999, splitList.Last().Count());
}
[Fact]
public void Split_Returns_Pages_Of_One_When_More_Pages_Are_Requested_Than_There_Are_Items_To_Page()
{
//arrange
var list = Enumerable.Range(1, 9);
//act
var splitList = list.Split(10);
//assert
Assert.Equal(9, splitList.Count());
Assert.Equal(1, splitList.First().Count());
Assert.Equal(1, splitList.Last().Count());
}
}
}