Пример #1
0
        private static void SubtestReadWriteMessage(MessageStream stream, LengthPrefixStyle lps, Action reset)
        {
            var rand = new Random(Environment.TickCount);
            var msgs = Enumerable.Range(0, 64).Select(_ =>
            {
                var msg = new byte[ReaderWriterTests.GetMaxLength(lps, rand.Next(16, 1024))];
                rand.NextBytes(msg);
                return(msg);
            }).ToList();

            msgs.ForEach(stream.WriteMessage);

            reset();

            foreach (var msg in msgs)
            {
                var msg2 = stream.ReadMessage();

                Assert.That(msg2, Is.EqualTo(msg));
            }
        }