コード例 #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));
        }
コード例 #2
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));
        }
コード例 #3
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));
        }