Ejemplo n.º 1
0
        public void Load()
        {
            var random = new Random();

            var localChannelNumber = (uint)random.Next(0, int.MaxValue);
            var data = new byte[random.Next(10, 20)];

            random.NextBytes(data);
#if TUNING
            var offset             = random.Next(2, 4);
            var size               = random.Next(5, 9);
            var channelDataMessage = new ChannelDataMessage(localChannelNumber, data, offset, size);
#else
            var offset             = 0;
            var size               = data.Length;
            var channelDataMessage = new ChannelDataMessage(localChannelNumber, data);
#endif
            var bytes  = channelDataMessage.GetBytes();
            var target = new ChannelDataMessage();

            target.Load(bytes);

            Assert.IsTrue(target.Data.SequenceEqual(data.Take(offset, size)));
#if TUNING
            Assert.AreEqual(0, target.Offset);
            Assert.AreEqual(size, target.Size);
#endif
        }
        public void Load()
        {
            var random = new Random();

            var localChannelNumber = (uint)random.Next(0, int.MaxValue);
            var data = CryptoAbstraction.GenerateRandom(random.Next(10, 20));

            var offset             = random.Next(0, data.Length - 1);
            var size               = random.Next(0, data.Length - offset);
            var channelDataMessage = new ChannelDataMessage(localChannelNumber, data, offset, size);
            var bytes              = channelDataMessage.GetBytes();
            var target             = new ChannelDataMessage();

            target.Load(bytes, 1, bytes.Length - 1); // skip message type

            Assert.IsTrue(target.Data.SequenceEqual(data.Take(offset, size)));
            Assert.AreEqual(0, target.Offset);
            Assert.AreEqual(size, target.Size);
        }