public void TestReadLongString() { var reader = new Amf0Reader(); using (var f = new FileStream("../../../../samples/amf0/misc/longstring.amf0", FileMode.Open)) { var data = new byte[f.Length]; f.Read(data); Assert.IsTrue(reader.TryGetLongString(data, out var dataRead, out var consumed)); Assert.AreEqual(string.Concat(Enumerable.Repeat("abc", 32767)), dataRead); Assert.AreEqual(consumed, f.Length); } }
public void TestLongString() { var writer = new Amf0Writer(); var reader = new Amf0Reader(); using (var sc = new SerializationContext()) { for (int i = 0; i < 1000; i++) { var val = string.Concat(Enumerable.Repeat(Guid.NewGuid().ToString(), 2000)); writer.WriteBytes(val, sc); var buffer = new byte[sc.MessageLength]; sc.GetMessage(buffer); reader.TryGetLongString(buffer, out var readValue, out var consumed); Assert.AreEqual(val, readValue); Assert.AreEqual(buffer.Length, consumed); } } }