Ejemplo n.º 1
0
        public void TestBubbleSort_EmptyJaggedArrayFirstItemDesc_ArgumentException()
        {
            var jaggedArray = new int[0][];

            int parameter(int[] arr) => arr[0];

            Assert.Throws <ArgumentException>(() => BubbleAlgorithm.BubbleSort(jaggedArray, parameter));
        }
Ejemplo n.º 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>(() => BubbleAlgorithm.BubbleSort(jaggedArray, null));
        }
Ejemplo n.º 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 }
            };

            int parameter(int[] arr) => arr[0];

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(jaggedArray, parameter));
        }
Ejemplo n.º 4
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 },
            };

            int parameter(int[] arr) => arr[0];

            BubbleAlgorithm.BubbleSort(jaggedArray, parameter, true);

            Assert.AreEqual(expected, jaggedArray);
        }
Ejemplo n.º 5
0
 public void TestBubbleSort_NullByNull_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(null, null));
 }
Ejemplo n.º 6
0
        public void TestBubbleSort_NullByFirstItemDesc_ArgumentNullException()
        {
            int parameter(int[] arr) => arr[0];

            Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(null, parameter));
        }