public void TestReadXml() { var reader = new Amf0Reader(); using (var f = new FileStream("../../../../samples/amf0/misc/xml.amf0", FileMode.Open)) { var data = new byte[f.Length]; f.Read(data); Assert.IsTrue(reader.TryGetXmlDocument(data, out var dataRead, out var consumed)); Assert.AreNotEqual(dataRead.GetElementsByTagName("a").Count, 0); Assert.AreNotEqual(dataRead.GetElementsByTagName("b").Count, 0); Assert.IsNotNull(dataRead.GetElementsByTagName("b")[0].Attributes["value"], "1"); Assert.AreEqual(consumed, f.Length); } }
public void TestXml() { var writer = new Amf0Writer(); var reader = new Amf0Reader(); using (var sc = new SerializationContext()) { var xml = new XmlDocument(); var elem = xml.CreateElement("price"); xml.AppendChild(elem); writer.WriteBytes(xml, sc); var buffer = new byte[sc.MessageLength]; sc.GetMessage(buffer); Assert.IsTrue(reader.TryGetXmlDocument(buffer, out var ud, out var consunmed)); Assert.IsNotNull(ud); Assert.AreNotEqual(ud.GetElementsByTagName("price").Count, 0); Assert.AreEqual(consunmed, buffer.Length); } }