示例#1
0
 public void BubbleSort_Test_1()
 {
     int[] nums     = { 1, 3, 2 };
     int[] expected = { 1, 2, 3 };
     int[] actual   = sortAlgos.BubbleSort(nums);
     CollectionAssert.AreEqual(expected, actual);
 }
示例#2
0
        public void BubbleSortTest()
        {
            var sortedList = SortAlgorithms.BubbleSort(new List <int>()
            {
                100, 2, 4473, 1, 474, 5, 7, 3, 55, 4, 8, 12
            });
            var list = sortedList as int[] ?? sortedList.ToArray();

            Assert.AreEqual(list.ElementAt(1), 2);
            Assert.AreEqual(list.ElementAt(6), 8);
            Assert.AreEqual(list.Count(), 12);
        }
示例#3
0
        public void TestLowBubble()
        {
            SetUp1(false);
            SortAlgorithms.BubbleSort(arrayTest);

            bool same = true;

            for (int i = 0; i < arrayTest.Length && same; i++)
            {
                if (arrayTest[i] != solutionLow[i])
                {
                    same = false;
                }
            }

            Assert.IsTrue(same);
        }
示例#4
0
        public void TestHighRepBubble()
        {
            SetUp3(true);
            SortAlgorithms.BubbleSort(arrayTest);

            bool same = true;

            for (int i = 0; i < arrayTest.Length && same && (i + 1 < arrayTest.Length); i++)
            {
                if (arrayTest[i] > arrayTest[i + 1])
                {
                    same = false;
                }
            }

            Assert.IsTrue(same);
        }
 public void TestBubbleSort()
 {
     originalList = new List <int>(new int[] { 5, 4, 3, 1, 2 });
     SortAlgorithms.BubbleSort(originalList);
     CollectionAssert.AreEqual(sortedList, originalList);
 }