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