public void Modify_TrimSpecialCharacters_cat() { Modify newMod = new Modify("cat!"); string result = newMod.TrimSpecialCharacters(); Assert.AreEqual("cat", result); }
static string ValidateWord(string word) { Modify modifyWord = new Modify(word); tryagain: while (word == "") { TypeLine("Don't be shy! Please enter your word: "); word = Console.ReadLine(); goto tryagain; } while (word.Contains(" ")) { TypeLine("Please enter a valid word with no spaces: "); word = Console.ReadLine(); goto tryagain; } if (modifyWord.ContainSpecialCharacters()) { TypeLine("Your word contains special characters. Are you sure you would like to proceed? Y/N"); tryCharacterAgain: string continueCharacterQuestion = Console.ReadLine().ToLower(); if (continueCharacterQuestion == "y" || continueCharacterQuestion == "yes") { TypeLine("Would you like to remove all non alphabetical characters?"); tryRemoveAgain: string continueRemoveQuestion = Console.ReadLine().ToLower(); if (continueRemoveQuestion == "y" || continueRemoveQuestion == "yes") { word = modifyWord.RemoveAllNonAlphaCharacters(); } else if (continueRemoveQuestion != "n" && continueRemoveQuestion != "no") { TypeLine("Sorry I didn't catch that. Would you like to remove all non alphabetical characters from your word? Y/N"); goto tryRemoveAgain; } else { TypeLine("Would you like to trim punctuation from the start and end of your word?"); tryTrimAgain: string continueTrimQuestion = Console.ReadLine().ToLower(); if (continueTrimQuestion == "y" || continueTrimQuestion == "yes") { word = modifyWord.TrimSpecialCharacters(); } else if (continueTrimQuestion != "n" && continueTrimQuestion != "no") { TypeLine("Sorry I didn't catch that. Would you like to remove the punctuation at the beginning and end of your word? Y/N"); goto tryTrimAgain; } } } else if (continueCharacterQuestion == "n" || continueCharacterQuestion == "no") { TypeLine("Please enter a new word: "); word = Console.ReadLine(); goto tryagain; } else { TypeLine("Sorry, I didn't catch that! Are you sure you would like to proceed with special characters? Y/N"); goto tryCharacterAgain; } } return(word); }