public void Success_WhenMultipleLinesMultipleWords() { var dict = new Dictionary <string, string> { { "word1", "repl_word1" }, { "word2", "repl_word2" }, { "word3", "repl_word3" } }; var testStr = new [] { "word words word1", "word words word2", "word words word3" }; var expected = new [] { "word words repl_word1", "word words repl_word2", "word words repl_word3" };; var result = WordReplacer.ReplaceWordsInStrings(testStr, dict); Assert.True(expected.SequenceEqual(result)); }
public void Replace_SentenceWithPunctuation_String() { string oldSentence = "This, is? new... sentence! i.s."; string replacedWord = "is"; string newWord = "ar"; string newSentence = "Thar, ar? new... sentence! i.s."; Assert.AreEqual(newSentence, WordReplacer.Replace(oldSentence, replacedWord, newWord)); }
public void Replace_WordsAreWeirdCase_String() { string oldSentence = "ThIs iS sI wIsisISis"; string replacedWord = "is"; string newWord = "ar"; string newSentence = "ThAr aR sI wArarARar"; Assert.AreEqual(newSentence, WordReplacer.Replace(oldSentence, replacedWord, newWord)); }
public void Replace_WordsStartWithCaps_String() { string oldSentence = "This Is New Sentence"; string replacedWord = "is"; string newWord = "ar"; string newSentence = "Thar Ar New Sentence"; Assert.AreEqual(newSentence, WordReplacer.Replace(oldSentence, replacedWord, newWord)); }
public void Replace_WordsAreAllCaps_String() { string oldSentence = "THIS IS NEW SENTENCE"; string replacedWord = "is"; string newWord = "ar"; string newSentence = "THAR AR NEW SENTENCE"; Assert.AreEqual(newSentence, WordReplacer.Replace(oldSentence, replacedWord, newWord)); }
public void Replace_WillReplaceWordsInSentence_String() { string oldSentence = "This is new sentence"; string replacedWord = "is"; string newWord = "ar"; string newSentence = "Thar ar new sentence"; Assert.AreEqual(newSentence, WordReplacer.Replace(oldSentence, replacedWord, newWord)); }
public void Success_WhenEmptyDictionary() { var dict = new Dictionary <string, string>(); var testStr = new [] { "word words word1" }; var expected = new [] { "word words word1" }; var result = WordReplacer.ReplaceWordsInStrings(testStr, dict); Assert.True(expected.SequenceEqual(result)); }
public void Success_WhenLineWithDifferentSeparators() { var dict = new Dictionary <string, string> { { "word1", "repl_word1" } }; var testStr = new [] { "word words word1!word1 word1??!word1" }; var expected = new [] { "word words repl_word1!repl_word1 repl_word1??!repl_word1" }; var result = WordReplacer.ReplaceWordsInStrings(testStr, dict); Assert.True(expected.SequenceEqual(result)); }