-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathEnumerableSortingTests.cs
More file actions
48 lines (43 loc) · 1.52 KB
/
EnumerableSortingTests.cs
File metadata and controls
48 lines (43 loc) · 1.52 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
namespace QueryKit.UnitTests;
using FluentAssertions;
using QueryKit.WebApiTestProject.Entities;
using SharedTestingHelper.Fakes;
public class EnumerableSortingTests
{
[Fact]
public async Task can_sort_items_with_mixed_order_directions()
{
// Arrange
var personOne = new FakeTestingPersonBuilder()
.WithTitle("alpha")
.WithAge(10)
.WithBirthMonth(BirthMonthEnum.January)
.Build();
var personTwo = new FakeTestingPersonBuilder()
.WithTitle("beta")
.WithAge(100)
.WithBirthMonth(BirthMonthEnum.February)
.Build();
var personThree = new FakeTestingPersonBuilder()
.WithTitle("beta")
.WithAge(50)
.WithBirthMonth(BirthMonthEnum.March)
.Build();
var personFour = new FakeTestingPersonBuilder()
.WithTitle("beta")
.WithAge(20)
.WithBirthMonth(BirthMonthEnum.April)
.Build();
List<TestingPerson> peopleList = [personOne, personTwo, personThree, personFour];
var input = $"Title desc, Age asc, BirthMonth desc";
// Act
var appliedQueryable = peopleList.ApplyQueryKitSort(input);
var people = appliedQueryable.ToList();
// Assert
people.Count.Should().Be(4);
people[0].Id.Should().Be(personFour.Id);
people[1].Id.Should().Be(personThree.Id);
people[2].Id.Should().Be(personTwo.Id);
people[3].Id.Should().Be(personOne.Id);
}
}