public void Bubble_IntSortHUGE_CorrectOrder()
        {
            // Arrange
            CustomList <int> jumble = new CustomList <int>(1000);

            for (int i = 0; i < 1000; i++)
            {
                jumble.Add(rng.Next(0, 1000));
            }
            bool expected = true;
            bool actual   = true;

            // Act
            jumble.BubbleSort();
            for (int i = 0; i < jumble.Count - 1; i++)
            {
                if (i > i + 1)
                {
                    actual = false;
                }
            }

            //  Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void BubbleSort_HigherNumberFirst_ReturnsHigherNumberFirst()
        {
            CustomList <int> unsortedList = new CustomList <int>()
            {
                2, 1
            };
            int expected = 2;
            int result   = (unsortedList.BubbleSort(unsortedList))[0];

            Assert.AreEqual(expected, result);
        }
Exemple #3
0
        public void MenuItemNine_CheckSort_Count() //naming convbention 'method, underscore, expected result. whenever third item needed, add an extra underscore. nned to add areference.
        {                                          //arrange
            CustomList <int> sortList = new CustomList <int>();

            sortList.Add(99);
            sortList.Add(33);
            sortList.Add(55);
            sortList.Add(44);
            sortList.Add(22);

            sortList.BubbleSort();

            //Assert

            Assert.AreEqual(sortList.Count, 0);
        }
        public void ListOfStringSortTest()
        {
            //Arrange
            CustomList <string> stringList = new CustomList <string>();
            string expected = "alligatorboycatdog";

            //Act
            stringList.Add("boy");
            stringList.Add("alligator");
            stringList.Add("dog");
            stringList.Add("cat");
            CustomList <string> .BubbleSort(stringList);

            string actual = stringList.ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void Bubble_IntSort_CorrectOrder()
        {
            // Arrange
            CustomList <int> jumble = new CustomList <int>()
            {
                9, 10, 3, 4, 8, 5, 0, 1, 2, 7, 6
            };


            CustomList <int> expected = new CustomList <int>()
            {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            CustomList <int> actual = jumble;

            // Act
            actual.BubbleSort();


            //  Assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void BubbleSort_StringSort_CorrectOrder()
        {
            // Arrange
            CustomList <string> jumble = new CustomList <string>()
            {
                "Hello", "Apple", "Cat", "Zoo", "Bunny"
            };

            CustomList <string> arranged = new CustomList <string>()
            {
                "Apple", "Bunny", "Cat", "Hello", "Zoo"
            };
            bool expected = true;
            bool actual;

            // Act
            jumble.BubbleSort();
            actual = jumble.Equals(arranged);

            //  Assert
            Assert.AreEqual(expected, actual);
        }
        public void ListSortTest()
        {
            //Arrange
            CustomList <int> numbers  = new CustomList <int>();
            string           expected = "123456789";

            //Act
            numbers.Add(3);
            numbers.Add(1);
            numbers.Add(4);
            numbers.Add(2);
            numbers.Add(6);
            numbers.Add(5);
            numbers.Add(9);
            numbers.Add(7);
            numbers.Add(8);
            CustomList <int> .BubbleSort(numbers);

            string actual = numbers.ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }