public void SortBySumUsingInterface_UnsortedArray_ReturnsSortedArray() { int[][] testArr = new int[5][] { new int[3] { 10, 4, 8 }, // 22 new int[5] { 7, 3, 8, 1, 2 }, // 21 new int[2] { -10, 25 }, // 15 new int[4] { -2, 0, 27, -5 }, // 20 new int[1] { 25 } // 25 }; int[][] sortedExpectedArr = new int[5][] { new int[] { -10, 25 }, new int[] { -2, 0, 27, -5 }, new int[] { 7, 3, 8, 1, 2 }, new int[] { 10, 4, 8 }, new int[] { 25 } }; var comparer = new CompairSums(); Array.Sort(testArr, comparer.Compare); Assert.AreEqual(testArr, sortedExpectedArr); }
public void SortBySum_NullArray_ThrowsArgumentNullExceptions() { var comparer = new CompairSums(); var ex = Assert.Catch <ArgumentNullException>(() => Array.Sort(null, comparer)); StringAssert.Contains("Value cannot be null.", ex.Message); }