Beispiel #1
0
        public void DecreaseMaxItemBubbleSortTests()
        {
            for (int j = 0; j < CountRepeat; j++)
            {
                var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode());

                ArraySorter.BubbleSort(array, ComparatorFactory.GetMaxItemComparer(false));

                Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Max(), (a, b) => a < b));
            }
        }
Beispiel #2
0
        public void IncreaseMinItemBubbleIComparerSortTests()
        {
            for (int j = 0; j < CountRepeat; j++)
            {
                var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode());

                ArraySorter.BubbleSort(array, ComparatorFactory.GetMinItemComparisonDelegate(true));

                Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Min(), (a, b) => a > b));
            }
        }
Beispiel #3
0
        public void DecreaseAmountBubbleSortIComparerTests()
        {
            for (int j = 0; j < CountRepeat; j++)
            {
                var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode());

                ArraySorter.BubbleSort(array, ComparatorFactory.GetAmountComparisonDelegate(false));

                Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Sum(), (a, b) => a < b));
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            /*Console.WriteLine("Entrer une taille de Tableau :");
             * int sizeTable = Convert.ToInt32(Console.ReadLine());
             * for (int i = 0; i < sizeTable; i++)
             *  Console.WriteLine("Entrer un nombre :");
             *  int number = Convert.ToInt32(Console.ReadLine());
             * {
             *  int arr[i] = number;
             * }*/
            int[] integer = new int[10] {
                23, 9, 85, 12, 99, 34, 60, 15, 100, 1
            };

            ArraySorter arraySorter = new ArraySorter();



            arraySorter.Ecriture(integer);
            Console.WriteLine("First table: ");
            arraySorter.Lecture();
            Console.WriteLine("Insertion Sort :");
            arraySorter.InsertionSort(integer);
            arraySorter.Lecture();

            int[] integer2 = new int[5] {
                78, 55, 45, 98, 13
            };

            arraySorter.Ecriture(integer2);
            Console.WriteLine("Second table: ");
            arraySorter.Lecture();
            Console.WriteLine("Bubble Sort :");
            arraySorter.BubbleSort(integer2);
            arraySorter.Lecture();
        }
Beispiel #5
0
        public void BubbleSortTest_ArrayIsNull_ThrowsArgumentNullException(int[][] array)
        {
            var comparator = ComparatorFactory.GetAmountComparer(true);

            Assert.Throws <ArgumentNullException>(() => ArraySorter.BubbleSort(array, comparator));
        }