示例#1
0
        public void TestExplicitDefine1()
        {
            var settings = new PreprocessorSettings();

            Environment.SetEnvironmentVariable("foo", "foo_val");
            settings.ExplicitDeclarationRequired = false;
            XmlDocument    doc = _Preprocess("TestExplicitDefine.xml", settings);
            XPathNavigator nav = doc.CreateNavigator();

            AssertNodeValue(nav, "/root/@foo", "foo_val");
        }
示例#2
0
 private static XmlDocument _Preprocess(string filename, PreprocessorSettings settings)
 {
     using (XmlReader input = GetInput(filename))
     {
         using (XmlWriter output = GetOutput())
         {
             ConfigPreprocessor preprocessor = new ConfigPreprocessor(settings);
             preprocessor.PreProcess(
                 input, output, new TestResolver(FAKE_ROOT + filename), new Uri(FAKE_ROOT + filename));
         }
         return(ReadOutputDoc());
     }
 }
示例#3
0
        public void TestInitialDefine()
        {
            var settings = new PreprocessorSettings();
            var defs     = new Dictionary <string, string>();

            defs["foo"] = "foo_val";
            settings.InitialDefinitions          = defs;
            settings.ExplicitDeclarationRequired = false;
            XmlDocument    doc = _Preprocess("TestExplicitDefine.xml", settings);
            XPathNavigator nav = doc.CreateNavigator();

            AssertNodeValue(nav, "/root/@foo", "foo_val");
        }
        public void TestExplicitDefine2()
        {
            var settings = new PreprocessorSettings();

            try
            {
                Environment.SetEnvironmentVariable("foo", "foo_val");
                settings.ExplicitDeclarationRequired = true;
                _Preprocess("TestExplicitDefine.xml", settings);
            }
            finally
            {
                Environment.SetEnvironmentVariable("foo", null);
            }
        }