コード例 #1
0
        public void SortingBySumOfElementsTest_WithSameRow()
        {
            int[][] source = new int[][]
            {
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
            };

            int[][] expected = new int[][]
            {
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
            };

            SortArrayWithInterface.Sort(source, new Comparators.CompareBySum());

            Assert.AreEqual(source, expected);
        }
コード例 #2
0
        public void SortingByMaxElementsTest_WithNormalArray()
        {
            int[][] source = new int[][]
            {
                new int[] { 1, 2, 3, 4, 5 },
                new int[] { -1, -2, -3, -4 },
                new int[] { 6, 7 },
                new int[] { -10, -20 }
            };

            int[][] expected = new int[][]
            {
                new int[] { -10, -20 },
                new int[] { -1, -2, -3, -4 },
                new int[] { 1, 2, 3, 4, 5 },
                new int[] { 6, 7 }
            };
            SortArrayWithInterface.Sort(source, new Comparators.CompareByMaxElement());

            Assert.AreEqual(source, expected);
        }
コード例 #3
0
        public void SortingByMinElementsTest_WithNormalArray()
        {
            int[][] source = new int[][]
            {
                new int[] { 4, 5, 6, 7, 8 },
                new int[] { 1, 2, 3 },
                new int[] { 12, 13 },
                new int[] { 9, 10, 11 },
            };

            int[][] expected = new int[][]
            {
                new int[] { 1, 2, 3 },
                new int[] { 4, 5, 6, 7, 8 },
                new int[] { 9, 10, 11 },
                new int[] { 12, 13 },
            };
            SortArrayWithInterface.Sort(source, new Comparators.CompareByMinElements());

            Assert.AreEqual(source, expected);
        }
コード例 #4
0
        public void SortingByMinElementsTest_WithMaxValueAndMinValue()
        {
            int[][] source = new int[][]
            {
                new int[] { -10, 10, int.MinValue, int.MaxValue, 1 },
                new int[] { -123456, 10, 111, 5632, 1, -11111 },
                new int[] { int.MaxValue, 1345 },
                new int[] { -100000000, 123456, 1 },
                new int[] { 1 },
            };
            int[][] expected = new int[][]
            {
                new int[] { -10, 10, int.MinValue, int.MaxValue, 1 },
                new int[] { -100000000, 123456, 1 },
                new int[] { -123456, 10, 111, 5632, 1, -11111 },
                new int[] { 1 },
                new int[] { int.MaxValue, 1345 },
            };

            SortArrayWithInterface.Sort(source, new Comparators.CompareByMinElements());

            Assert.AreEqual(source, expected);
        }
コード例 #5
0
        public void SortingByMaxElementsTest_WithOneElementInRow()
        {
            int[][] source = new int[][]
            {
                new int[] { 10 },
                new int[] { -100 },
                new int[] { 1000 },
                new int[] { -1000 },
                new int[] { 200 },
            };

            int[][] expected = new int[][]
            {
                new int[] { -1000 },
                new int[] { -100 },
                new int[] { 10 },
                new int[] { 200 },
                new int[] { 1000 }
            };

            SortArrayWithInterface.Sort(source, new Comparators.CompareByMaxElement());

            Assert.AreEqual(source, expected);
        }
コード例 #6
0
 public void SortingByMaxElementsTests_WithEmptyRow_ThrowArgumentException()
 => Assert.Throws <ArgumentException>(() => SortArrayWithInterface.Sort(new int[][] { new int[] { 1, 2 }, new int[] { } }, new Comparators.CompareByMaxElement()));
コード例 #7
0
 public void SortingByMinfElementsTests_WithNullRow_ThrowArgumentNullException()
 => Assert.Throws <ArgumentNullException>(() => SortArrayWithInterface.Sort(new int[][] { new int[] { 1, 2 }, null }, new Comparators.CompareByMinElements()));
コード例 #8
0
 public void SortingBySumOfElementsTests_WithEmptyArray_ThrowArgumentException()
 => Assert.Throws <ArgumentException>(() => SortArrayWithInterface.Sort(new int[0][], new Comparators.CompareBySum()));
コード例 #9
0
 public void SortingByMaxElementsTests_WithNullArray_ThrowArgumentNullException()
 => Assert.Throws <ArgumentNullException>(() => SortArrayWithInterface.Sort(null, new Comparators.CompareByMaxElement()));
コード例 #10
0
 public void SortTests_WithNullComparer_ThrowArgumentNullException()
 => Assert.Throws <ArgumentNullException>(() => SortArrayWithInterface.Sort(new int[][] { new int[] { 1, 2 }, new int[] { 1 } }, null));