public void TestReadDate() { var reader = new Amf0Reader(); using (var f = new FileStream("../../../../samples/amf0/misc/date.amf0", FileMode.Open)) { var data = new byte[f.Length]; f.Read(data); Assert.IsTrue(reader.TryGetDate(data, out var dataRead, out var consumed)); Assert.AreEqual(dataRead.Year, 2019); Assert.AreEqual(dataRead.Month, 2); Assert.AreEqual(dataRead.Day, 11); Assert.AreEqual(consumed, data.Length); } }
public void TestDate() { var writer = new Amf0Writer(); var reader = new Amf0Reader(); var date = DateTime.Now; using (var sc = new SerializationContext()) { writer.WriteBytes(date, sc); var buffer = new byte[sc.MessageLength]; sc.GetMessage(buffer); Assert.IsTrue(reader.TryGetDate(buffer, out var val, out var consumed)); Assert.AreEqual(val.Date, date.Date); Assert.AreEqual(val.Hour, date.Hour); Assert.AreEqual(val.Minute, date.Minute); Assert.AreEqual(val.Second, date.Second); Assert.AreEqual(val.Millisecond, date.Millisecond); Assert.AreEqual(val.Kind, date.Kind); Assert.AreEqual(consumed, buffer.Length); } }