コード例 #1
0
 public void TestDefineConst()
 {
     using (XmlReader input = GetInput("TestDefineConst.xml"))
     {
         using (XmlWriter output = GetOutput())
         {
             ConfigPreprocessor preprocessor = new ConfigPreprocessor();
             ConfigPreprocessorEnvironment env =
                 preprocessor.PreProcess(input, output, _resolver, null );
             Assert.AreEqual(
                 env._GetConstantDef( "var1" ).Value, "value1" );
         }
     }
 }
コード例 #2
0
        public void TestInclude()
        {
            using (XmlReader input = GetInput("TestIncluder.xml"))
            {
                ConfigPreprocessorEnvironment env;
                using ( XmlWriter output = GetOutput() )
                {
                    ConfigPreprocessor preprocessor = new ConfigPreprocessor();
                    env = preprocessor.PreProcess( input, output, new TestResolver( FAKE_ROOT + "TestIncluder.xml" ), new Uri(FAKE_ROOT + "TestIncluder.xml" ) );
                }
                AssertNodeExists( ReadOutputDoc().CreateNavigator(),
                                  "/includer/included/included2" );

                Assert.AreEqual( env.Fileset.Length, 3 );
                Assert.AreEqual(GetTestPath("TestIncluder.xml"), env.Fileset[0]);
                Assert.AreEqual(GetTestPath(String.Format(
                    "Subfolder{0}TestIncluded.xml", Path.DirectorySeparatorChar)), env.Fileset[1]);
                Assert.AreEqual(GetTestPath("TestIncluded2.xml"), env.Fileset[2]);
            }
        }
コード例 #3
0
 public void TestIncludeFileWithSpacesInName()
 {
     using (XmlReader input = GetInput("Test Include File With Spaces.xml"))
     {
         ConfigPreprocessorEnvironment 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(GetTestPath("Test Include File With Spaces.xml"), env.Fileset[0]);
     }
 }
コード例 #4
0
 private static XmlDocument _Preprocess(string filename)
 {
     using( XmlReader input = GetInput( filename ) )
     {
         using ( XmlWriter output = GetOutput() )
         {
             ConfigPreprocessor preprocessor = new ConfigPreprocessor();
             preprocessor.PreProcess(
                 input, output, new TestResolver( FAKE_ROOT + filename  ), new Uri( FAKE_ROOT + filename  )  );
         }
         return ReadOutputDoc();
     }
 }
コード例 #5
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);
            }
        }
コード例 #6
0
 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));
         }
     }
 }