forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssertOrderedBy.cs
31 lines (29 loc) · 871 Bytes
/
AssertOrderedBy.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
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace NHibernate.Test.Linq.ByMethod
{
public static class AssertOrderedBy
{
public static void Ascending<T>(IList<T> result, Func<T, IComparable> keySelector)
{
if (result == null) throw new ArgumentNullException("result");
for (var i = 0; i < result.Count - 1; i++)
{
var first = result[i];
var second = result[i + 1];
Assert.That(keySelector(first), Is.LessThanOrEqualTo(keySelector(second)));
}
}
public static void Descending<T>(IList<T> result, Func<T, IComparable> keySelector)
{
if (result == null) throw new ArgumentNullException("result");
for (var i = 0; i < result.Count - 1; i++)
{
var first = result[i];
var second = result[i + 1];
Assert.That(keySelector(first), Is.GreaterThanOrEqualTo(keySelector(second)));
}
}
}
}