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); }
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); }
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); }