Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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));
        }