public void TestWriteValue() { TextWriter writer = new StringWriter(); SimpleValue attr = new SimpleValue("test", true); attr.WriteValue(writer, true); Assert.AreEqual("'test'", writer.ToString()); Binary bin = new Binary(new byte[] { 0x1, 0xF }); SimpleValue attrBin = new SimpleValue(bin, true); writer = new StringWriter(); attrBin.WriteValue(writer, false); Assert.AreEqual("AQ8=", writer.ToString()); SimpleValue content = new SimpleValue("some content with & and\n"); writer = new StringWriter(); content.WriteValue(writer, false); Assert.AreEqual("<![CDATA[" + content.GetString() + "]]>", writer.ToString()); content = new SimpleValue(0xF); writer = new StringWriter(); content.WriteValue(writer, false); Assert.AreEqual(0xF.ToString(), writer.ToString()); byte[] bytes = new byte[100]; for (byte i = 0; i < 100; i++) { bytes[i] = i; } bin = new Binary(bytes); content = new SimpleValue(bin); writer = new StringWriter(); content.WriteValue(writer, true); Assert.IsTrue(writer.ToString().IndexOf("\n") >= 0); }