示例#1
0
        public void TestBubbleSort_EmptyJaggedArrayFirstItemDesc_ArgumentException()
        {
            var jaggedArray = new int[0][];
            Func <int[], int[], int> compare = new FirstItemComparer().Compare;

            Assert.Throws <ArgumentException>(() => BubbleAlgorithmDelegateToComparator.BubbleSort(jaggedArray, (IComparer <int[]>)compare.Target));
        }
示例#2
0
        public void TestBubbleSort_JaggedArrayByNull_ArgumentNullException()
        {
            var jaggedArray = new int[][]
            {
                new int[] { 1 },
                new int[] { 2, 5, 2, 2, 1 },
                new int[] { 3, 1, 2 },
                new int[] { 4, 1, 4, 3 }
            };

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmDelegateToComparator.BubbleSort(jaggedArray, null));
        }
示例#3
0
        public void TestBubbleSort_JaggedArrayWithNullByFirstItemDesc_ArgumentNullException()
        {
            var jaggedArray = new int[][]
            {
                new int[] { 1 },
                new int[] { 2, 5, 2, 2, 1 },
                null,
                new int[] { 4, 1, 4, 3 }
            };
            Func <int[], int[], int> compare = new FirstItemComparer().Compare;

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmDelegateToComparator.BubbleSort(jaggedArray, (IComparer <int[]>)compare.Target));
        }
示例#4
0
        public void TestBubbleSortByMax_JaggedArray_SortedArray()
        {
            var jaggedArray = new int[][]
            {
                new int[] { 1, 2, 3, 4, 5, 6, 7 },
                new int[] { 1, 2, 3, 4 },
                new int[] { 1, 2, 3, 4, 5 },
                new int[] { 1, 2 }
            };
            var expected = new int[][]
            {
                new int[] { 1, 2 },
                new int[] { 1, 2, 3, 4 },
                new int[] { 1, 2, 3, 4, 5 },
                new int[] { 1, 2, 3, 4, 5, 6, 7 }
            };

            BubbleAlgorithmDelegateToComparator.BubbleSortByMax(jaggedArray);

            Assert.AreEqual(expected, jaggedArray);
        }
示例#5
0
        public void TestBubbleSort_JaggedArrayByFirstItemDesc_SortedArray()
        {
            var jaggedArray = new int[][]
            {
                new int[] { 1 },
                new int[] { 2, 5, 2, 2, 1 },
                new int[] { 3, 1, 2 },
                new int[] { 4, 1, 4, 3 }
            };
            var expected = new int[][]
            {
                new int[] { 4, 1, 4, 3 },
                new int[] { 3, 1, 2 },
                new int[] { 2, 5, 2, 2, 1 },
                new int[] { 1 },
            };
            Func <int[], int[], int> compare = new FirstItemComparer().Compare;

            BubbleAlgorithmDelegateToComparator.BubbleSort(jaggedArray, (IComparer <int[]>)compare.Target, true);

            Assert.AreEqual(expected, jaggedArray);
        }
示例#6
0
 public void TestBubbleSort_NullByNull_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmDelegateToComparator.BubbleSort(null, null));
 }
示例#7
0
        public void TestBubbleSort_NullByFirstItemDesc_ArgumentNullException()
        {
            Func <int[], int[], int> compare = new FirstItemComparer().Compare;

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmDelegateToComparator.BubbleSort(null, (IComparer <int[]>)compare.Target));
        }