Exemple #1
0
        public void Sort_WithNullString_NullArgumentException(string textQuery)
        {
            //Arrange
            ITextSorter alphabeticSorter = new AlphabeticDescendentSorter();

            //Action
            Exception ex = Assert.Catch <Exception>(() => alphabeticSorter.Sort(textQuery));

            //Assert
            StringAssert.Contains(TextConstants.TEXT_NULL_ERROR, ex.Message);
        }
Exemple #2
0
        public void Sort_WithSpaceWordDelimiter_FirstWordHasLetter_Z(string textQuery, string expectingWord)
        {
            //Arrange
            ITextSorter alphabeticSorter = new AlphabeticDescendentSorter();

            //Action
            string sorted    = alphabeticSorter.Sort(textQuery);
            string firstword = sorted.Split(TextConstants.SPLITTER).First();

            //Assert
            //Assert
            Assert.True(firstword == expectingWord);
        }
Exemple #3
0
        public void Sort_WithSpaceDelimiterForWords_WordAlphabeticalAscendant(string textQuery)
        {
            //Arrange
            ITextSorter alphabeticSorter = new AlphabeticDescendentSorter();


            //Action
            string sorted = alphabeticSorter.Sort(textQuery);

            string[] words            = sorted.Split(TextConstants.SPLITTER);
            bool     incrementalOrder = true;

            for (int i = 1; i < words.Length; i++)
            {
                if (words[i - 1][0] < words[i][0])
                {
                    incrementalOrder = false;
                }
            }

            //Assert
            Assert.IsTrue(incrementalOrder);
        }