public void TestWhenAllEqualValue()
        {
            int[] testingArray = { 1, 1, 1, 1, 1, 1 };
            var   quickSort    = new QuickSortWithComparer <int>();

            quickSort.Sort(testingArray);
            CollectionAssert.AreEqual(new int[] { 1, 1, 1, 1, 1, 1 }, testingArray);
        }
        public void TestWhenArrayHaveNullPointer()
        {
            string[] testingArray = { "123", "afsdf", "a132rer", "adffdg", null, "124234", "adsfd" };
            var      quickSort    = new QuickSortWithComparer <string>();

            quickSort.Sort(testingArray);
            CollectionAssert.AreEqual(new string[] { null, "123", "124234", "a132rer", "adffdg", "adsfd", "afsdf" }, testingArray);
        }
        public void TestDefaultArray()
        {
            int[] testingArray = { 7, 2, 4, -3, 15, 0, -10 };
            var   quickSort    = new QuickSortWithComparer <int>();

            quickSort.Sort(testingArray);
            CollectionAssert.AreEqual(new int[] { -10, -3, 0, 2, 4, 7, 15 }, testingArray);
        }
        public void TestReversedSortedArray()
        {
            int[] testingArray = { 6, 5, 4, 3, 2, 1, 0 };
            var   quickSort    = new QuickSortWithComparer <int>();

            quickSort.Sort(testingArray);
            CollectionAssert.AreEqual(new int[] { 0, 1, 2, 3, 4, 5, 6 }, testingArray);
        }
        public void TestWhenNullArray()
        {
            int[] testingArray = null;
            var   quickSort    = new QuickSortWithComparer <int>();

            quickSort.Sort(testingArray);
            Assert.IsNull(testingArray);
        }
        public void TestCheckWhenZeroCountElements()
        {
            int[] testingArray = {};
            var   quickSort    = new QuickSortWithComparer <int>();

            quickSort.Sort(testingArray);
            CollectionAssert.AreEqual(new int[] {}, testingArray);
        }
        public void TestDifferenceComparer()
        {
            int[] testingArrayBigger = { 7, 2, 4, -3, 15, 0, -10 };
            var   quickSort          = new QuickSortWithComparer <int>();

            quickSort.Comparer = new ComparerBigger();
            quickSort.Sort(testingArrayBigger);
            CollectionAssert.AreEqual(new int[] { -10, -3, 0, 2, 4, 7, 15 }, testingArrayBigger);

            int[] testingArrayLower = { 7, 2, 4, -3, 15, 0, -10 };
            quickSort.Comparer = new ComparerLower();
            quickSort.Sort(testingArrayLower);
            CollectionAssert.AreEqual(new int[] { 15, 7, 4, 2, 0, -3, -10 }, testingArrayLower);
        }
Esempio n. 8
0
        public void CustomSorted()
        {
            var quickSort = new QuickSortWithComparer <int>();

            quickSort.Sort(GenerateValue());
        }