public void TestIncludeStack() { using (XmlReader input = GetInput("TestIncludeStack1.xml")) { PreprocessorEnvironment env; using (XmlWriter output = GetOutput()) { ConfigPreprocessor preprocessor = new ConfigPreprocessor(); env = preprocessor.PreProcess(input, output, new TestResolver(FAKE_ROOT + "TestIncludeStack1.xml"), new Uri(FAKE_ROOT + "TestIncludeStack1.xml")); } AssertNodeExists(ReadOutputDoc().CreateNavigator(), "/TestIncludeStack1/TestIncludeStack2/TestIncludeStack3"); AssertNodeExists(ReadOutputDoc().CreateNavigator(), "/TestIncludeStack1/TestIncludeStack4"); Assert.AreEqual(env.Fileset.Length, 4); Assert.AreEqual(GetTestPath("TestIncludeStack1.xml"), env.Fileset[0].LocalPath); Assert.AreEqual(GetTestPath(String.Format( "Subfolder{0}TestIncludeStack2.xml", Path.DirectorySeparatorChar)), env.Fileset[1].LocalPath); Assert.AreEqual(GetTestPath("TestIncludeStack3.xml"), env.Fileset[2].LocalPath); Assert.AreEqual(GetTestPath("TestIncludeStack4.xml"), env.Fileset[3].LocalPath); } }
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 TestDefineConst() { using (XmlReader input = GetInput("TestDefineConst.xml")) { using (XmlWriter output = GetOutput()) { ConfigPreprocessor preprocessor = new ConfigPreprocessor(); PreprocessorEnvironment env = preprocessor.PreProcess(input, output, _resolver, null); Assert.AreEqual(env.EvalSymbol("var1").GetTextValue(), "value1"); } } }
public void TestMissingIncludeFile() { string filename = "TestMissingIncludeFile.xml"; using (XmlReader input = GetInput(filename)) { using (XmlWriter output = GetOutput()) { ConfigPreprocessor preprocessor = new ConfigPreprocessor(); preprocessor.PreProcess( input, output, new FileNotFoundTestResolver(FAKE_ROOT + filename), new Uri(FAKE_ROOT + filename)); } } }
public void TestIncludeFileWithSpacesInName() { using (XmlReader input = GetInput("Test Include File With Spaces.xml")) { PreprocessorEnvironment env; using (XmlWriter output = GetOutput()) { ConfigPreprocessor preprocessor = new ConfigPreprocessor(); env = preprocessor.PreProcess(input, output, new TestResolver(FAKE_ROOT + "Test Include File With Spaces.xml"), new Uri(FAKE_ROOT + "Test Include File With Spaces.xml")); } XmlDocument doc = ReadOutputDoc(); AssertNodeValue(doc, "/element", "value"); Assert.AreEqual(env.Fileset.Length, 1); Assert.AreEqual(new Uri(GetTestPath("Test Include File With Spaces.xml")), env.Fileset[0]); } }
public void TestIncludeVariable() { using (XmlReader input = GetInput("TestIncludeVariable.xml")) { PreprocessorEnvironment env; using (XmlWriter output = GetOutput()) { ConfigPreprocessor preprocessor = new ConfigPreprocessor(); env = preprocessor.PreProcess(input, output, new TestResolver(FAKE_ROOT + "TestIncludeVariable.xml"), new Uri(FAKE_ROOT + "TestIncludeVariable.xml")); } AssertNodeExists(ReadOutputDoc().CreateNavigator(), "/includeVariable/included/included2"); Assert.AreEqual(env.Fileset.Length, 3); Assert.AreEqual(GetTestPath("TestIncludeVariable.xml"), env.Fileset[0].LocalPath); Assert.AreEqual(GetTestPath(@"Subfolder\TestIncluded.xml"), env.Fileset[1].LocalPath); Assert.AreEqual(GetTestPath("TestIncluded2.xml"), env.Fileset[2].LocalPath); } }