Exemple #1
0
        public void MacroProcessor_Basic2()
        {
            var macros = new MacroProcessor();

            macros.Add("var1", "HELLO");
            macros.Add("var2", "WORLD");

            Assert.AreEqual("HELLO", macros["var1"]);
            Assert.AreEqual("HELLO", macros["VAR1"]);
            Assert.IsNull(macros["VAR3"]);

            Assert.AreEqual("HELLO", macros.Expand("$(var1)"));
            Assert.AreEqual("WORLD", macros.Expand("$(var2)"));
            Assert.AreEqual("HELLO WORLD", macros.Expand("$(var1) $(var2)"));
            Assert.AreEqual("prefix HELLO suffix", macros.Expand("prefix $(var1) suffix"));
            Assert.AreEqual("HELLO WORLD", macros.Expand("$(VAR1) $(VAR2)"));

            macros.Clear();
            Assert.AreEqual("$(var1)", macros.Expand("$(var1)"));

            macros["VAR3"] = "TEST";
            Assert.AreEqual("TEST", macros["var3"]);
            Assert.AreEqual("TEST", macros["VAR3"]);
            Assert.AreEqual("TEST", macros.Expand("$(var3)"));
            Assert.AreEqual("TEST", macros.Expand("$(VAR3)"));
        }