Esempio n. 1
0
        public void ReplaceSingle()
        {
            var input  = "[$ data $] asdfasdfasdfasdf";
            var result = StupidReplacer.Replace(input, token => "data");

            Assert.AreEqual("data asdfasdfasdfasdf", result);
        }
Esempio n. 2
0
 public static void RunStupidReplacer()
 {
     StupidReplacer.Replace(InputData, token =>
     {
         var t = "[$" + token + "$]";
         return(ReplacementData[t]);
     });
 }
Esempio n. 3
0
        public void ReplaceRecursive()
        {
            var input = "[$ data $] asdfasdfasdfasdf";

            var result = StupidReplacer.Replace(input, token =>
            {
                if (token == " data ")
                {
                    return("in [$ inside $]");
                }
                if (token == " inside ")
                {
                    return("bum!");
                }
                return(null);
            });

            Assert.AreEqual("in bum! asdfasdfasdfasdf", result);
        }
Esempio n. 4
0
        public void ReplaceMultiple()
        {
            var input  = "[$ data1 $][$ data2 $] asdfasdfasdfasdf[$ data3 $]";
            var result = StupidReplacer.Replace(input, token =>
            {
                if (token == " data1 ")
                {
                    return("data1");
                }
                if (token == " data2 ")
                {
                    return("data2");
                }
                if (token == " data3 ")
                {
                    return("data3");
                }
                return(token);
            });

            Assert.AreEqual("data1data2 asdfasdfasdfasdfdata3", result);
        }