Skip to content

CollectionOrderedConstraint

Chris Maddock edited this page Feb 14, 2016 · 7 revisions

CollectionOrderedConstraint tests that an IEnumerable is ordered. If the actual value passed does not implement IEnumerable, an exception is thrown.

Constructor

CollectionOrderedConstraint()

Syntax

Is.Ordered

Modifiers

...Descending
...By(string propertyName)
...Using(IComparer comparer)
...Using<T>(IComparer<T> comparer)
...Using<T>(Comparison<T> comparer)

Examples of Use

int[] iarray = new int[] { 1, 2, 3 };
string[] sarray = new string[] { "c", "b", "a" };
string[] sarray2 = new string[] ( "a", "aa", "aaa" );
Assert.That(iarray, Is.Ordered);
Assert.That(sarray, Is.Ordered.Descending);
Assert.That(sarray2, Is.Ordered.By("Length"));

Notes

  1. Modifiers may be combined and may appear in any order. If the same modifier is used more than once, the result is undefined.
Clone this wiki locally