Example #1
0
        public void TLBoolSerialization()
        {
            var boolTrue = new TLBool(true);
            var boolFalse = new TLBool(false);

            CollectionAssert.AreEquivalent(bufferTrue, boolTrue.ToBytes());
            CollectionAssert.AreEquivalent(bufferFalse, boolFalse.ToBytes());

            using (var streamTrue = new MemoryStream())
            {
                boolTrue.ToStream(streamTrue);
                var buffer = new byte[4];
                streamTrue.Position = 0;
                streamTrue.Read(buffer, 0, 4);
                CollectionAssert.AreEquivalent(bufferTrue, buffer);
            }

            using (var streamFalse = new MemoryStream())
            {
                boolFalse.ToStream(streamFalse);
                var buffer = new byte[4];
                streamFalse.Position = 0;
                streamFalse.Read(buffer, 0, 4);
                CollectionAssert.AreEquivalent(bufferFalse, buffer);
            }
        }