public void QuickSortingTest1() { // Arrange int[] unsorted1 = { 1, -5, 0, 15, -4, 27 }; int[] unsorted2 = { 1, -5, 0, 15, -4, 27 }; // Act Array.Sort(unsorted2); SortingClass.QuickSorting(unsorted1, 0, unsorted1.Length - 1); // Assert CollectionAssert.AreEqual(unsorted2, unsorted1); }
public void QuickSortingTest2() { // Arrange int[] unsorted = new int[100]; Random random = new Random(); for (int i = 0; i < unsorted.Length; ++i) { unsorted[i] = random.Next(1, 10); } // Act SortingClass.QuickSorting(unsorted, 0, unsorted.Length - 1); // Assert Assert.IsTrue(IsArraySorted(unsorted)); }
public void QuickSortingTest_AcceptsEmptyArray_ThrowsArgumentException() { int[] unsorted = new int[0]; Assert.ThrowsException <ArgumentException>(() => SortingClass.QuickSorting(unsorted, 0, unsorted.Length - 1)); }
public void QuickSortingTest_AcceptsNullArray_ThrowsNullReferenceException() { int[] unsorted = null; Assert.ThrowsException <NullReferenceException>(() => SortingClass.QuickSorting(unsorted, 0, unsorted.Length - 1)); }