public void ValidateMethod_InvalidBothSortingBounds_ArgumentException() { List <int> arrayIn = new List <int> { 1, 2, 3 }; SortDataValidator.Validate(arrayIn, -1, 5, null); }
public void ValidateMethod_TypeHaveNoCompareTo_InvalidOperationException() { List <object> arrayIn = new List <object> { new object { }, new object { }, new object { } }; SortDataValidator.Validate(arrayIn, null, null, null); }
/// <summary> /// Sort the entire of any implementation of the generic IList interface using quicksort algorithm, /// as a comparer used the presented comparer. /// </summary> /// <param name="left">Null is replaced on zero.</param> /// <param name="right">Null is replaced on the last index of the array.</param> /// <param name="comparer">Null is replaced by the default comparer.</param> /// <exception cref="ArgumentNullException">The array is null.</exception> /// <exception cref="ArgumentException">The presented bounds are not valid.</exception> /// <exception cref="InvalidOperationException">Comparer is null, and the presented type don't implement IComparable or it's generic analogue.</exception> public static void QuickSort <T>(this IList <T> arr, int?left, int?right, IComparer <T> comparer) { SortDataValidator.Validate(arr, left, right, comparer); if (arr.Count == 0) { return; } int _left = left ?? 0; int _right = right ?? (arr.Count - 1); comparer = comparer ?? Comparer <T> .Default; QuickSort(arr, _left, _right, comparer); }
public void ValidateMethod_ArrayNull_ArgumentNullException() { List <int> arrayIn = null; SortDataValidator.Validate(arrayIn, null, null, null); }