Ejemplo n.º 1
0
        public void Serialize()
        {
            var orderId      = Guid.NewGuid();
            var mail         = new CancelOrderMail(1, Guid.NewGuid(), 2, orderId);
            var serialized   = (Dictionary)mail.Serialize();
            var deserialized = (CancelOrderMail)Mail.Deserialize(serialized);

            Assert.Equal(1, deserialized.blockIndex);
            Assert.Equal(2, deserialized.requiredBlockIndex);
            Assert.Equal(orderId, deserialized.OrderId);
        }
Ejemplo n.º 2
0
        public void Serialize_DotNet_Api()
        {
            var orderId = Guid.NewGuid();
            var mail    = new CancelOrderMail(1, Guid.NewGuid(), 2, orderId);

            var formatter = new BinaryFormatter();

            using var ms = new MemoryStream();
            formatter.Serialize(ms, mail);
            ms.Seek(0, SeekOrigin.Begin);

            var deserialized = (CancelOrderMail)formatter.Deserialize(ms);

            Assert.Equal(mail.Serialize(), deserialized.Serialize());
        }