public void Sort_WithNullString_NullArgumentException(string textQuery) { //Arrange ITextSorter alphabeticSorter = new AlphabeticAscendentSorter(); //Action Exception ex = Assert.Catch <Exception>(() => alphabeticSorter.Sort(textQuery)); //Assert StringAssert.Contains(TextConstants.TEXT_NULL_ERROR, ex.Message); }
public void Sort_WithSpaceWordDelimiter_LastWordHasLetter_Z(string textQuery, string expectingWord) { //Arrange ITextSorter alphabeticSorter = new AlphabeticAscendentSorter(); //Action string sorted = alphabeticSorter.Sort(textQuery); string firstword = sorted.Split(TextConstants.SPLITTER).Last(); //Assert //Assert Assert.True(firstword == expectingWord); }
public void Sort_WithSpaceDelimiterForWords_WordAlphabeticalAscendant(string textQuery) { //Arrange ITextSorter alphabeticSorter = new AlphabeticAscendentSorter(); //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); }
private ITextSorter InstanceCreateTextSorter(eSortMode sortMode) { ITextSorter newInstance = null; switch (sortMode) { case eSortMode.AlphabeticAsc: newInstance = new AlphabeticAscendentSorter(); break; case eSortMode.AlphabeticDesc: newInstance = new AlphabeticDescendentSorter(); break; case eSortMode.LenghtAsc: newInstance = new WordLengthSorter(); break; default: throw new NotImplementedException(TextConstants.SORTER_CRITERIA_NOTIMPLEMENTED); } return(newInstance); }