-
Notifications
You must be signed in to change notification settings - Fork 29
/
ThenByDescendingTests.cs
64 lines (58 loc) · 1.93 KB
/
ThenByDescendingTests.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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ShittyLINQ;
using System;
namespace ShittyTests
{
[TestClass]
public class ThenByDescendingTests
{
[TestMethod]
public void ThenByDescending_WithoutComparer()
{
// Arrange
var items = System.Linq.Enumerable.OrderBy(new (string prop1, int prop2)[]
{
("test", 1),
("test", 2),
("test", 3),
}, i => i.prop1);
// Act
var result = items.ThenByDescending(i => i.prop2);
// Assert
Assert.IsNotNull(result);
using (var enumerator = result.GetEnumerator())
{
enumerator.MoveNext();
Assert.AreEqual(3, enumerator.Current.prop2);
enumerator.MoveNext();
Assert.AreEqual(2, enumerator.Current.prop2);
enumerator.MoveNext();
Assert.AreEqual(1, enumerator.Current.prop2);
}
}
[TestMethod]
public void ThenByDescending_WithComparer()
{
// Arrange
var items = System.Linq.Enumerable.OrderBy(new (string prop1, string prop2)[]
{
("test", "a"),
("test", "B"),
("test", "c"),
}, i => i.prop1);
// Act
var result = items.ThenByDescending(i => i.prop2, StringComparer.OrdinalIgnoreCase);
// Assert
Assert.IsNotNull(result);
using (var enumerator = result.GetEnumerator())
{
enumerator.MoveNext();
Assert.AreEqual("c", enumerator.Current.prop2);
enumerator.MoveNext();
Assert.AreEqual("B", enumerator.Current.prop2);
enumerator.MoveNext();
Assert.AreEqual("a", enumerator.Current.prop2);
}
}
}
}