public void ArraySort_ValidData_MaxAscending_Test() { int[][] arr1 = { new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 } }; int[][] resultArr1 = { new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 }, new[] { 1, -2, 7, -4 } }; CollectionAssert.AreEqual(resultArr1, ArraySortDelegate.BubleSort(arr1, new MaxElementComparer(true).Compare)); }
public void ArraySort_ValidData_SumDescending_Test() { int[][] arr1 = { new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 } }; int[][] resultArr1 = { new[] { 2, 5, -3 }, new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 } }; CollectionAssert.AreEqual(ArraySortDelegate.BubleSort(arr1, new SumElementComparer(false).Compare), resultArr1); }
static void Main(string[] args) { int[] array = { 1, 5, 3, 9 }; ArraySortDelegate del = new ArraySortDelegate(ArraySortASC); int[] r = del(array); Console.WriteLine("Ascending:"); for (int i = 0; i < r.Length; i++) { Console.WriteLine($"r[{i}] = {r[i]}"); } Console.WriteLine("Descending:"); del = new ArraySortDelegate(ArraySortDESC); del(array); for (int i = 0; i < array.Length; i++) { Console.WriteLine($"array[{i}] = {array[i]}"); } }
public void ArraySort_InvalidData_Test(int[][] arg1) { Assert.Throws <ArgumentNullException>(() => ArraySortDelegate.BubleSort(arg1, new SumElementComparer(false).Compare)); }