public void TestArray() { var writer = new Amf0Writer(); var reader = new Amf0Reader(); var array = new List <object>() { 1, 3.0, "string", new DateTime(2019, 2, 11), false, new List <object>() { null, 3, "string2", "string2" } }; using (var sc = new SerializationContext()) { writer.WriteBytes(array, sc); var buffer = new byte[sc.MessageLength]; sc.GetMessage(buffer); Assert.IsTrue(reader.TryGetStrictArray(buffer, out var val, out var consumed)); Assert.IsTrue((double)val[0] == 1.0); Assert.IsTrue((double)val[1] == 3.0); Assert.IsTrue((string)val[2] == "string"); Assert.IsTrue((DateTime)val[3] == new DateTime(2019, 2, 11)); Assert.IsTrue((bool)val[4] == false); var e5 = (List <object>)val[5]; Assert.IsTrue(e5[0] == null); Assert.IsTrue((double)e5[1] == 3.0); Assert.IsTrue((string)e5[2] == "string2"); Assert.IsTrue((string)e5[3] == "string2"); } }
public void TestReadArray() { var reader = new Amf0Reader(); using (var f = new FileStream("../../../../samples/amf0/misc/array.amf0", FileMode.Open)) { var data = new byte[f.Length]; f.Read(data); var arrayData = new List <object> { 1.0d, 2.0d, 3.0d, 4.0d, "a", "asdf", "eee" }; Assert.IsTrue(reader.TryGetStrictArray(data, out var dataRead, out var consumed)); Assert.IsTrue(arrayData.SequenceEqual(dataRead)); Assert.AreEqual(consumed, data.Length); } }