Example #1
0
        public void ExecuteMethod_ArraySortByMaxValueAndAscending_ReturnSortedArray()
        {
            int[][] array = new int[][]
            {
                new int[] { 1, 2, 10 },
                new int[] { 5, 6, 7 },
                new int[] { 0, 1, 2 }
            };

            int[][] expected = new int[][]
            {
                new int[] { 0, 1, 2 },
                new int[] { 5, 6, 7 },
                new int[] { 1, 2, 10 }
            };

            JaggedSort.Execute(array, new ComparatorMaxValueAscend());

            Assert.IsTrue(CheckJaggedArrays(expected, array));
        }
Example #2
0
        public void ExecuteMethod_ArrayWithEmptyElements_ReturnSortedArray()
        {
            int[][] array = new int[][]
            {
                new int[] { 1, 2, 3 },
                new int[] { },
                new int[] { 5, 6, 7 }
            };

            int[][] expected = new int[][]
            {
                new int[] { 5, 6, 7 },
                new int[] { 1, 2, 3 },
                new int[] { }
            };

            JaggedSort.Execute(array, new ComparatorSumDescend());

            Assert.IsTrue(CheckJaggedArrays(expected, array));
        }
        public void ExecuteMethodWithDelegate_ArrayWithNullElements_ReturnSortedArray()
        {
            int[][] array = new int[][]
            {
                new int[] { 1, 2, 3 },
                null,
                new int[] { 5, 6, 7 }
            };

            int[][] expected = new int[][]
            {
                null,
                new int[] { 1, 2, 3 },
                new int[] { 5, 6, 7 }
            };

            ComparatorSumAscend comparator = new ComparatorSumAscend();

            JaggedSort.Execute(array, comparator.Compare);

            Assert.IsTrue(CheckJaggedArrays(expected, array));
        }
        public void ExecuteMethodWithDelegate_ArraySortByMinValueAndDescending_ReturnSortedArray()
        {
            int[][] array = new int[][]
            {
                new int[] { 11, -2, 3 },
                new int[] { 5, 6, 7 },
                new int[] { 0, -1, 2 }
            };

            int[][] expected = new int[][]
            {
                new int[] { 5, 6, 7 },
                new int[] { 0, -1, 2 },
                new int[] { 11, -2, 3 }
            };

            ComparatorMinValueDescend comparator = new ComparatorMinValueDescend();

            JaggedSort.Execute(array, comparator.Compare);

            Assert.IsTrue(CheckJaggedArrays(expected, array));
        }