public void shellSortTest5() { Sorts target = new Sorts(); // Creates an instance of the class to be tested (a target object/instance of the Sorts class) int SIZE = 15; // The size of the array int[] actual = { 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5}; int[] expected = new int[SIZE];//expected array declared of type int with 'SIZE' number of elements used to hold the required or expected order of elements Array.Copy(actual, expected, SIZE);//the actual array 's content is copied to the expectedArray Array.Sort(expected); //the expected array is sorted by the .NET Array.Sort Method target.shellSort(actual, SIZE); //the actual array is now passed (by reference) to the shellSort method for testing CollectionAssert.ReferenceEquals(expected, actual); //Checks if compared objects are of the same instance CollectionAssert.AreEqual(expected, actual);//compares the content of the expected and actual collection }
public void shellSortTest2() { Sorts target = new Sorts(); // Creates an instance of the class to be tested (a target object/instance of the Sorts class) int SIZE = 2; // The size of the array int[] actual = new int[SIZE]; //actual array declared of type int with 'SIZE' number of elements /*populateArray(Size ofArray, Minimum Random Value, Maximum Random Value): This function returns a populated array of a size and random values in range specified by the functions arguments*/ Array.Copy(populateArray(SIZE, 20, 100), actual, SIZE); /*Copies the randomly populated array from the populateArray function to the actual array*/ int[] expected= new int[SIZE];//expected array declared of type int with 'SIZE' number of elements used to store the required or expected order of elements Array.Copy(actual, expected, SIZE);//the actual array 's content is copied to the expected array Array.Sort(expected); //the expected array is sorted by the .NET Array.Sort Method target.shellSort(actual, SIZE); //the actual array is now passed (by reference) to the shellSort method CollectionAssert.ReferenceEquals(expected, actual); //Checks if compared objects are of the same instance for (int count = 0; count < SIZE; count++) // loop that iterates through the arrays (collections) and checks if each element are respectively identical Assert.AreEqual(expected[count], actual[count]); }
public void shellSortTest3() { Sorts target = new Sorts(); // Creates an instance of the class to be tested (a target object/instance of the Sorts class) int SIZE = 10; // The size of the array int[] actual= {-7, -5, 1,1,2,4,4,6,7,9}; //the actual array declared with a sorted list of positive and negative values with duplicate values int[] expected = new int[SIZE];//expected array declared of type int with 'SIZE' number of elements used to store the required or expected order of elements Array.Copy(actual, expected, SIZE);//the actual array 's content is copied to the expected array Array.Sort(expected); //the expected array is sorted by the .NET Array.Sort Method target.shellSort(actual, SIZE); //the actual array is now passed (by reference) to the shellSort method CollectionAssert.ReferenceEquals(expected, actual); //Checks if compared objects are of the same instance for (int count = 0; count < SIZE; count++) // loop that iterates through the arrays (collections) and checks if each element are respectively identical Assert.AreEqual(expected[count], actual[count]); }
public void shellSortTest1() { Sorts target = new Sorts(); // Creates an instance of the class to be tested (a target object/instance of the Sorts class) int SIZE = 100; // The size of the array int[] actual = new int[SIZE]; //actual array declared of type int with 'SIZE' number of elements /*populateArray(Size ofArray, Minimum Random Value, Maximum Random Value): This function returns a populated array of a size and random values in range specified by the functions arguments*/ Array.Copy(populateArray(SIZE, 300, 850), actual, SIZE); /*Copies the randomly populated array from the populateArray function to the actual array*/ int[] expected = new int[SIZE];//expected array declared of type int with 'SIZE' number of elements used to hold the required or expected order of elements Array.Copy(actual, expected, SIZE);//the actual array 's content is copied to the expected array Array.Sort(expected); //the expected array is sorted by the .NET Array.Sort Method target.shellSort(actual, SIZE); //the actual array is now passed (by reference) to the shellSort method CollectionAssert.ReferenceEquals(expected, actual); //Checks if compared objects are of the same instance Assert.AreEqual(expected[0], actual[0]);//compares and checks the first index (low boundary) Assert.AreEqual(expected[SIZE - 1], actual[SIZE - 1]);//compares and checks the last index (high boundary) Assert.AreEqual(expected[(SIZE/2)], actual[(SIZE/2)]);//checks the middle index }