Exemplo n.º 1
0
 public void XmlWriterWrapperCanBeUsedInUsingWithTextWriter()
 {
     var el = new Element("img", "src=myimage.gif");
     var expected = "<img src=\"myimage.gif\" />";
     var actual = String.Empty;
     using (var textWriter = new StringWriter())
     using (var xml = new XmlWriterWrapper(textWriter))
     {
         el.Render(xml);
         actual = textWriter.ToString();
     }
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 2
0
 public void CanRenderToStream()
 {
     string expected = "<p>Hello World</p>";
     byte[] buffer = new byte[expected.Length];
     using (MemoryStream stream = new MemoryStream(buffer))
     {
         Element para = new Element("p").Update("Hello World");
         para.Render(stream);
         string actual = System.Text.ASCIIEncoding.ASCII.GetString(buffer);
         Assert.AreEqual(expected, actual);
     }
 }