Ejemplo n.º 1
0
        public void Sort_PositiveInts_ListOfNumbers()
        {
            //Arrange
            CustomList <int> intList = new CustomList <int>();

            string expected = "0135679121824";
            string actual   = "";

            //Act
            for (int i = 0; i < 10; i++)
            {
                if ((i % 2) > 0)
                {
                    intList.Add(i);
                }
                else
                {
                    intList.Add(i * 3);
                }
            }

            intList.Sort();
            actual = intList.ToString();

            //Assert
            Assert.AreEqual(actual, expected);
        }
        public void Sort_StringsSomeAreRepeated_SortedList()
        {
            //Arrange
            CustomList <string> customList = new CustomList <string>();

            customList.Add("Hello");
            customList.Add("world");
            customList.Add("!");
            customList.Add(" ");
            customList.Add("kappa");
            customList.Add("kappa");

            CustomList <string> expectedResult = new CustomList <string>();

            expectedResult.Add(" ");
            expectedResult.Add("!");
            expectedResult.Add("Hello");
            expectedResult.Add("kappa");
            expectedResult.Add("kappa");
            expectedResult.Add("world");
            //Act
            CustomList <string> result = customList.Sort();

            //Assert
            Assert.IsTrue(ListsAreEqual(expectedResult, result));
        }
Ejemplo n.º 3
0
        public void Sort_9Strings_SortedProperly()
        {
            // Arrange
            CustomList <string> customList = new CustomList <string>()
            {
                "r", "a", "z", "d", "y", "A", "w", "h", "y", "a"
            };

            // Act
            customList.Sort();

            // Assert         //a a A d h r w y y z
            Assert.IsTrue(
                customList[0] == "a" &&
                customList[1] == "a" &&
                customList[2] == "A" &&
                customList[3] == "d" &&
                customList[4] == "h" &&
                customList[5] == "r" &&
                customList[6] == "w" &&
                customList[7] == "y" &&
                customList[8] == "y" &&
                customList[9] == "z"
                );
        }
Ejemplo n.º 4
0
        public void Sort_EmptyList_ReturnCount()
        {
            //Arrange
            CustomList <int> list1 = new CustomList <int>();
            int expectedResult     = 0;

            //Act
            list1.Sort();
            int count = list1.Count;

            //Assert
            Assert.AreEqual(expectedResult, count);
        }
Ejemplo n.º 5
0
        public void SortMethod_CollectionPreSortedChars_OrderUnchanged()
        {
            CustomList <char> list = new CustomList <char>()
            {
                'a', 'b', 'c', 'd', 'e', 'f'
            };
            string expected = "abcdef";
            string actual;

            list.Sort();
            actual = list.ToString();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void SortMethod_CollectionOfRandomIntsWithRepeats_SortedLowToHigh()
        {
            CustomList <int> list = new CustomList <int>()
            {
                8, 3, 6, 7, 1, 2, 5, 4, 2, 9, 6
            };
            string expected = "12234566789";
            string actual;

            list.Sort();
            actual = list.ToString();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void Sort_VerifyStringOrderAlreadySorted()
        {
            CustomList <string> list = new CustomList <string>()
            {
                "a", "b", "c", "d", "e", "f", "g"
            };
            CustomList <string> expected = new CustomList <string>()
            {
                "a", "b", "c", "d", "e", "f", "g"
            };

            list.Sort();

            Assert.AreEqual(expected.ToString(), list.ToString());
        }
Ejemplo n.º 8
0
        public void Sort_VerifyIntOrderAlreadySorted()
        {
            CustomList <int> list = new CustomList <int>()
            {
                3, 17, 23, 29, 37, 47, 71
            };
            CustomList <int> expected = new CustomList <int>()
            {
                3, 17, 23, 29, 37, 47, 71
            };

            list.Sort();

            Assert.AreEqual(expected.ToString(), list.ToString());
        }
Ejemplo n.º 9
0
            public void Sort_VerifyIntOrder()
            {
                CustomList <int> list = new CustomList <int>()
                {
                    2, 1, 5, 4, 6, 7, 3
                };
                CustomList <int> expected = new CustomList <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };

                list.Sort();

                Assert.AreEqual(expected.ToString(), list.ToString());
            }
Ejemplo n.º 10
0
        public void Sort_RandomIntList_ReturnEquivalentStringList()
        {
            //Arrange
            CustomList <int> list1 = new CustomList <int>()
            {
                10, 9, 5, 7, 6, 1, 4, 2, 3, 11, 12, 17, 16, 15, 13, 14, 20, 18, 8, 19
            };
            string expectedResult = "'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'";

            //Act
            list1.Sort();
            string result = list1.ToString();

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 11
0
        public void Sort_StringList_ReturnString()
        {
            //Arrange
            CustomList <string> list1 = new CustomList <string>()
            {
                "World", "Hello"
            };
            string expectedResult = "'Hello', 'World'";

            //Act
            list1.Sort();
            string result = list1.ToString();

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 12
0
        public void Sort_1Strings_Returns1String()
        {
            // Arrange
            CustomList <string> customList = new CustomList <string>()
            {
                "z"
            };

            // Act
            customList.Sort();

            // Assert         //a a A d h r w y y z
            Assert.IsTrue(
                customList[0] == "z"
                );
        }
Ejemplo n.º 13
0
        public void Sort_2StringsOutOfOrder_SortedProperly()
        {
            // Arrange
            CustomList <string> customList = new CustomList <string>()
            {
                "r", "a"
            };

            // Act
            customList.Sort();

            // Assert         //a a A d h r w y y z
            Assert.IsTrue(
                customList[0] == "a" &&
                customList[1] == "r"
                );
        }
Ejemplo n.º 14
0
        public void Sort_DecreasingIntList_ReturnIndexNine()
        {
            //Arrange
            CustomList <int> list1 = new CustomList <int>()
            {
                10, 9, 8, 7, 6, 5, 4, 3, 2, 1
            };
            int testIndex      = 9;
            int expectedResult = 10;

            //Act
            list1.Sort();
            int index = list1[testIndex];

            //Assert
            Assert.AreEqual(expectedResult, index);
        }
Ejemplo n.º 15
0
        public void Sort_IncreasingIntList_ReturnIndexZero()
        {
            //Arrange
            CustomList <int> list1 = new CustomList <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            int testIndex      = 0;
            int expectedResult = 1;

            //Act
            list1.Sort();
            int index = list1[testIndex];

            //Assert
            Assert.AreEqual(expectedResult, index);
        }
Ejemplo n.º 16
0
        public void Sort_2StringsInOrder_Returns2Strings()
        {
            // Arrange
            CustomList <string> customList = new CustomList <string>()
            {
                "a", "z"
            };

            // Act
            customList.Sort();

            // Assert         //a a A d h r w y y z
            Assert.IsTrue(
                customList[0] == "a" &&
                customList[1] == "z"
                );
        }
Ejemplo n.º 17
0
        public void Sort_IntList_ReturnIndexThree()
        {
            //Arrange
            CustomList <int> list1 = new CustomList <int>()
            {
                10, 5, 9, 2
            };
            int testIndex      = 3;
            int expectedResult = 10;

            //Act
            list1.Sort();
            int index = list1[testIndex];

            //Assert
            Assert.AreEqual(expectedResult, index);
        }
Ejemplo n.º 18
0
        //[ExpectedException(typeof(NullReferenceException))]
        public void Sort_1Null1String_Count1()
        {
            // Arrange
            CustomList <string> customList = new CustomList <string>()
            {
                null, "199"
            };

            // Act
            customList.Sort();

            // Assert
            Assert.IsTrue(
                customList[0] == "199" &&
                customList.Count == 1
                );
        }
Ejemplo n.º 19
0
        public void Sort_CharList_ListOfbglp()
        {
            //Arrange
            CustomList <char> intList = new CustomList <char>()
            {
                'b', 'p', 'l', 'g'
            };

            string expected = "bglp";
            string actual   = "";

            //Act
            intList.Sort();
            actual = intList.ToString();

            //Assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 20
0
        public void Sort_StringList_GetResult()
        {
            //Arrange
            CustomList <string> stringList = new CustomList <string>()
            {
                "cat", "dog", "rabbit", "bear"
            };
            CustomList <string> expected = new CustomList <string>()
            {
                "bear", "cat", "dog", "rabbit"
            };


            //Act
            stringList.Sort(stringList);
            //Assert
            Assert.AreEqual(expected.ToString(), stringList.ToString());
        }
Ejemplo n.º 21
0
        public void Sort_StringList_ListOfGreetings()
        {
            //Arrange
            CustomList <string> intList = new CustomList <string>()
            {
                "Hi,", "Salut,", "Zdravstvuyte", "Guten Tag,"
            };

            string expected = "Guten Tag,Hi,Salut,Zdravstvuyte";
            string actual   = "";

            //Act
            intList.Sort();
            actual = intList.ToString();

            //Assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 22
0
        public void Sort_PositiveAndNegativeDoubles_ListOfNumbers()
        {
            //Arrange
            CustomList <double> intList = new CustomList <double>()
            {
                8, 0.4, 11.1, -2.4
            };

            string expected = "-2.40.4811.1";
            string actual   = "";

            //Act
            intList.Sort();
            actual = intList.ToString();

            //Assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 23
0
        public void Sort_CharList_GetResultTwo()
        {
            //Arrange
            CustomList <char> charList = new CustomList <char>()
            {
                'A', 'Z', 'b', 'e', 'a', 'z'
            };
            CustomList <char> expected = new CustomList <char>()
            {
                'A', 'Z', 'a', 'b', 'e', 'z'
            };


            //Act
            charList.Sort(charList);
            //Assert
            Assert.AreEqual(expected.ToString(), charList.ToString());
        }
Ejemplo n.º 24
0
        public void Sort_StringList_GetResultTwo()
        {
            //Arrange
            CustomList <string> stringList = new CustomList <string>()
            {
                "A", "B", "a", "b"
            };
            CustomList <string> expected = new CustomList <string>()
            {
                "A", "a", "B", "b"
            };


            //Act
            stringList.Sort(stringList);
            //Assert
            Assert.AreEqual(expected.ToString(), stringList.ToString());
        }
Ejemplo n.º 25
0
        public void Sort_IntList_GetResult()
        {
            //Arrange
            CustomList <int> numberList = new CustomList <int>()
            {
                1, 3, 2, 4, 6, 5, 8, 7, 9
            };
            CustomList <int> expected = new CustomList <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };


            //Act
            numberList.Sort(numberList);
            //Assert
            Assert.AreEqual(expected.ToString(), numberList.ToString());
        }
Ejemplo n.º 26
0
        public void Sort_NegativeInt_ListOf5012345()
        {
            //Arrange
            CustomList <int> intList = new CustomList <int>()
            {
                5, 2, 3, -5, 1, 4, 0
            };

            string expected = "-5012345";
            string actual   = "";

            //Act
            intList.Sort();
            actual = intList.ToString();

            //Assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 27
0
        public void Sort_IntList_GetResultTwo()
        {
            //Arrange
            CustomList <int> numberList = new CustomList <int>()
            {
                70, 22, 34, 35, 69, 11
            };
            CustomList <int> expected = new CustomList <int>()
            {
                11, 22, 34, 35, 69, 70
            };


            //Act
            numberList.Sort(numberList);
            //Assert
            Assert.AreEqual(expected.ToString(), numberList.ToString());
        }
Ejemplo n.º 28
0
        public void Sort_4Ints_SortedProperly()
        {
            // Arrange
            CustomList <int> customList = new CustomList <int>()
            {
                199, 99, 104, 77
            };

            // Act
            customList.Sort();

            // Assert
            Assert.IsTrue(
                customList[0] == 77 &&
                customList[1] == 99 &&
                customList[2] == 104 &&
                customList[3] == 199
                );
        }
        public void Sort_IntegersSomeAreRepeated_SortedList()
        {
            //Arrange
            CustomList <int> customList = new CustomList <int>();

            customList.Add(4);
            customList.Add(2);
            customList.Add(9);
            customList.Add(4);
            customList.Add(8);

            CustomList <int> expectedResult = new CustomList <int>();

            expectedResult.Add(2);
            expectedResult.Add(4);
            expectedResult.Add(4);
            expectedResult.Add(8);
            expectedResult.Add(9);
            //Act
            CustomList <int> result = customList.Sort();

            //Assert
            Assert.IsTrue(ListsAreEqual(expectedResult, result));
        }