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"); }
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()); } }
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); } }