private void MergeSortTest(IMergeSorter mergeSorter) { int[] a = new int[] { 3, 7, 6, 2, 5, 9, 4, 8 }; mergeSorter.MergeSort(a, 0, a.Length - 1); for (int i = 0; i < a.Length; i++) { Assert.AreEqual(i + 2, a[i]); } }
private void MergeSortRandomArrayTest(IMergeSorter mergeSorter) { int[] a = GenerateRandomArray(100); int[] expected = (int[])a.Clone(); Array.Sort(expected); mergeSorter.MergeSort(a, 0, a.Length - 1); for (int i = 0; i < a.Length; i++) { Assert.AreEqual(expected[i], a[i]); } }