public void JaggedArraySortByRowsSumMethod(int[][] array)
    {
        IComparer <int[]> comparer = new ByRowsSumComparer();

        JaggedArraySort.Sort(array, comparer);

        Assert.True(IsSorted(array, comparer));
    }
    public void JaggedArraySortByRowsSumMethodByDelegates(int[][] array)
    {
        Comparison <int[]> comparer = SortCriteriasAsStaticMethods.ByRowsSum;

        JaggedArraySort.Sort(array, comparer);

        Assert.True(IsSorted(array, comparer));
    }
    public void JaggedArraySortByRowsMaxElemsMethod(int[][] array)
    {
        IComparer <int[]> comparer = new ByRowsMaxElemsComparer();

        JaggedArraySort.Sort(array, comparer);

        OutputToDebug(array);

        Assert.True(IsSorted(array, comparer));
    }
        public void SortByRowElementsSumReverseTests(int[][] jaggedArray, int[][] expected)
        {
            // Arrange
            // Act
            JaggedArraySort.SortByRowElementsSumReverse(jaggedArray);

            // Assert
            for (int i = 0; i < jaggedArray.Length; i++)
            {
                CollectionAssert.AreEqual(expected[i], jaggedArray[i]);
            }
        }
예제 #5
0
 public void SortInAscendingOrderBySumOfElements()
 {
     int[][] array = new int[3][] { new int[3] {
                                        1, 2, 3
                                    }, new int[3] {
                                        0, 1, -6
                                    }, new int[3] {
                                        10, 11, 12
                                    } };
     int[][] array1 = new int[3][] { array[1], array[0], array[2] };
     JaggedArraySort.DoSort(array, new ComparerBySumToUp());
     Assert.IsTrue(Equals(array, array1));
 }
예제 #6
0
 public void SortInDescendingOrderByAbsoluteMaxElements()
 {
     int[][] array = new int[3][] { new int[3] {
                                        1, 2, 3
                                    }, new int[3] {
                                        4, 5, -6
                                    }, new int[3] {
                                        0, 1, 2
                                    } };
     int[][] array1 = new int[3][] { array[1], array[0], array[2] };
     JaggedArraySort.DoSort(array, new ComparerByAbsoluteMaxToDown());
     Assert.IsTrue(Equals(array, array1));
 }
예제 #7
0
        public void BubbleSortMaxTest()
        {
            int[][] jaggedArray =
            {
                new int[] { 9,  39, 8, 8, 9 },
                new int[] { 6, 221,1 },
                new int[] { 0,   0, 0 }
            };

            int[][] result =
            {
                new int[] { 6, 221, 1 },
                new int[] { 9,  39,8, 8, 9 },
                new int[] { 0,   0, 0 }
            };

            Assert.AreEqual(JaggedArraySort.Sort(jaggedArray, new Max()), result);
        }
예제 #8
0
        public void BubbleSortTest()
        {
            int[][] arrayTest = new int[4][];
            arrayTest[0] = new[] { 10, 20 };
            arrayTest[1] = new[] { 1, 2, 8, 12 };
            arrayTest[2] = new[] { 5, 10, 16 };
            arrayTest[3] = new[] { 18, 1, 5, 6, 8 };



            int[][] arrayTest1 = new int[4][];
            arrayTest1[0] = new[] { 1, 2, 8, 12 };
            arrayTest1[1] = new[] { 10, 20 };
            arrayTest1[2] = new[] { 5, 10, 16 };
            arrayTest1[3] = new[] { 18, 1, 5, 6, 8 };


            ;
            Assert.IsTrue(arrayTest1.SequenceEqual(JaggedArraySort.Sort(arrayTest, new AscendingSumSort())));
        }
예제 #9
0
 public static void MinByDescTest(int[][] a, int[][] expected)
 {
     Assert.AreEqual(expected, JaggedArraySort.MinByDesc(a));
 }
예제 #10
0
 public static void SumByAscTest(int[][] a, int[][] expected)
 {
     Assert.AreEqual(expected, JaggedArraySort.SumByAsc(a));
 }
 public void BubbleSort_NullReferenceComparer_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => JaggedArraySort.BubbleSort(new int[][] { }, null));
 }
 public void BubbleSort_NullReferenceArray_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => JaggedArraySort.BubbleSort(null, new ByMaxElementDESC()));
 }
 public void BubbleSort_JaggedArrayWithNullArray_EqualToResult(int[][] array, int[][] result)
 {
     JaggedArraySort.BubbleSort(array, new BySumElementsASC());
     Assert.True(array.EqualTo(result));
     array.Equals(result);
 }
 public void BubbleSort_ComparerByMaxDESC_EqualToResult(int[][] array, int[][] result)
 {
     JaggedArraySort.BubbleSort(array, new ByMaxElementDESC());
     Assert.True(array.EqualTo(result));
 }