Ejemplo n.º 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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void TestBubbleSort_NullByFirstItemDesc_ArgumentNullException()
        {
            Func <int[], int[], int> compare = new FirstItemComparer().Compare;

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