public void SortByMaxElement_WithEmptyArray_ReturnArgumentException()
        {
            int[][]  actualArray = new int[][] { };
            SortType type        = SortType.increasing;

            Assert.Throws <ArgumentException>(() => BubbleSortInterfaceToDelegate.SortByMaxElement(ref actualArray, type));
        }
Esempio n. 2
0
 public void SortByElementSumUpDelegate_PositivTest(int[][] actual, int[][] expected, IComparer comparer)
 {
     BubbleSortInterfaceToDelegate.Sort(actual, delegate(int[] arr1, int[] arr2)
     {
         if ((arr1 == null) || (arr2 == null))
         {
             throw new ArgumentNullException();
         }
         if (ReferenceEquals(arr1, arr2))
         {
             return(0);
         }
         if (arr1.Sum() > arr2.Sum())
         {
             return(1);
         }
         else if ((arr1.Sum() < arr2.Sum()))
         {
             return(-1);
         }
         else
         {
             return(0);
         }
     });
     Assert.AreEqual(expected, actual);
 }
        public void SortBySum_WithNullArray_ReturnArgumentNullException()
        {
            int[][]  actualArray = null;
            SortType type        = SortType.increasing;

            Assert.Throws <ArgumentNullException>(() => BubbleSortInterfaceToDelegate.SortBySum(ref actualArray, type));
        }
        public void SortByMinElement_Decreasing_WithCorrectData_ReturnsCorrectResult()
        {
            int[][]  actualArray   = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5 }, new int[] { 10 } };
            int[][]  expectedArray = new int[][] { new int[] { 10 }, new int[] { 4, 5 }, new int[] { 1, 2, 3 } };
            SortType type          = SortType.decreasing;

            BubbleSortInterfaceToDelegate.SortByMinElement(ref actualArray, type);

            Assert.AreEqual(expectedArray, actualArray);
        }
Esempio n. 5
0
 public void SortByElementSumDown_PositivTest(int[][] actual, int[][] expected, IComparer comparer)
 {
     BubbleSortInterfaceToDelegate.Sort(actual, comparer);
     Assert.AreEqual(expected, actual);
 }