示例#1
0
 public InsertionSort()
 {
     algorithm = new InsertionSorting();
     displayInputMessage();
     this.complexity = "n-square";
     this.takeInput();
 }
示例#2
0
        public void Sort_PassEmptyArray_ReturnEmptyArray()
        {
            var insertSorting = new InsertionSorting();
            var sortedArray   = insertSorting.Sort(_emptyArray, 0, _emptyArray.Length - 1);

            CollectionAssert.AreEqual(sortedArray, _emptyArray);
        }
示例#3
0
        public void Sort_PassValidArray_ReturnSortedArray()
        {
            var insertSorting = new InsertionSorting();
            var sortedArray   = insertSorting.Sort(_toSortArray, 0, _toSortArray.Length - 1);

            CollectionAssert.AreEqual(sortedArray, _referenceSortedArray);
        }
示例#4
0
        public void Sort_PassOneElementArray_ReturnOneElementArray()
        {
            var insertSorting = new InsertionSorting();
            var sortedArray   = insertSorting.Sort(_oneElementArray, 0, _oneElementArray.Length - 1);

            CollectionAssert.AreEqual(sortedArray, _oneElementArray);
        }
        public void InsertionSorting_Sort__SuccessResult()
        {
            ISorting testClass = new InsertionSorting();

            int[] array = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
            testClass.Sort(array);

            array.Should().Equal(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
        }
示例#6
0
        public void InsertionSorting_Test()
        {
            var rand = new Random();

            var list = Enumerable
                       .Range(1, 10000)
                       .Select(x => rand.Next())
                       .ToList();

            var actual = InsertionSorting.Sort(list);

            list.Sort();

            Assert.Equal(list, actual);
        }
示例#7
0
 static void Main()
 {
     SelectionSorting.SelectionSortArray();
     InsertionSorting.InsertionSortArray();
     QuickSorting.QuickSortArray();
 }
示例#8
0
        public void InsertionSorting_Sort()
        {
            ISorting testClass = new InsertionSorting();

            testClass.Sort(SortedData);
        }