Example #1
0
        public void TestShouldReplaceInText()
        {
            Dictionary <char, string> mapping = new Dictionary <char, string>();

            mapping.Add('f', "FOO");
            StringWriter      sw       = new StringWriter();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.OmitXmlDeclaration = true;
            settings.Indent             = false;
            CharacterMappingXmlWriter writer = new CharacterMappingXmlWriter(XmlWriter.Create(sw, settings), mapping);

            writer.WriteElementString("foo", "fgh");
            writer.Close();
            Assert.IsTrue(sw.ToString() == "<foo>FOOgh</foo>");
        }
Example #2
0
        public void TestShouldNotEscape()
        {
            Dictionary <char, string> mapping = new Dictionary <char, string>();

            mapping.Add('(', "<");
            mapping.Add(')', ">");
            StringWriter      sw       = new StringWriter();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.OmitXmlDeclaration = true;
            settings.Indent             = false;
            CharacterMappingXmlWriter writer = new CharacterMappingXmlWriter(XmlWriter.Create(sw, settings), mapping);

            writer.WriteElementString("foo", "(%= bar%)");
            writer.Close();
            Assert.IsTrue(sw.ToString() == "<foo><%= bar%></foo>");
        }