public void TestBubbleSort_EmptyJaggedArrayFirstItemDesc_ArgumentException()
        {
            var jaggedArray = new int[0][];
            Func <int[], int[], int> compare = delegate(int[] a, int[] b) { return(a[0].CompareTo(b[0])); };

            Assert.Throws <ArgumentException>(() => BubbleAlgorithmComparatorToDelegate.BubbleSort(jaggedArray, compare));
        }
        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>(() => BubbleAlgorithmComparatorToDelegate.BubbleSort(jaggedArray, null));
        }
        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 = delegate(int[] a, int[] b) { return(a[0].CompareTo(b[0])); };

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmComparatorToDelegate.BubbleSort(jaggedArray, compare));
        }
        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 }
            };

            BubbleAlgorithmComparatorToDelegate.BubbleSortByMax(jaggedArray);

            Assert.AreEqual(expected, jaggedArray);
        }
        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 = delegate(int[] a, int[] b) { return(a[0].CompareTo(b[0])); };

            BubbleAlgorithmComparatorToDelegate.BubbleSort(jaggedArray, compare, true);

            Assert.AreEqual(expected, jaggedArray);
        }
 public void TestBubbleSort_NullByNull_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmComparatorToDelegate.BubbleSort(null, null));
 }
        public void TestBubbleSort_NullByFirstItemDesc_ArgumentNullException()
        {
            Func <int[], int[], int> compare = delegate(int[] a, int[] b) { return(a[0].CompareTo(b[0])); };

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithmComparatorToDelegate.BubbleSort(null, compare));
        }