Пример #1
0
 public void PacketStreamWriteWhenReadOnlyTest()
 {
     using (ILitePacketStream packetStream = new LitePacketStream(_randomizer.Bytes(_randomizer.Byte())))
     {
         Assert.Throws <InvalidOperationException>(() => packetStream.Write <byte>(_randomizer.Byte()));
     }
 }
Пример #2
0
        private void PacketStreamWritePrimitive <T>(T valueToWrite, byte[] expectedByteArray, bool adjustBuffer = true)
        {
            using (ILitePacketStream packetStream = new LitePacketStream())
            {
                Assert.Equal(LitePacketMode.Write, packetStream.Mode);

                packetStream.Write(valueToWrite);

                var adjustedBuffer = adjustBuffer ? expectedByteArray.Take(Marshal.SizeOf <T>()).ToArray() : expectedByteArray;

                Assert.Equal(adjustedBuffer, packetStream.Buffer);
            }
        }
Пример #3
0
        public void PacketStreamWriteNonPrimitiveTest()
        {
            using ILitePacketStream packetStream = new LitePacketStream();

            Assert.Throws <NotImplementedException>(() => packetStream.Write <object>(new object()));
        }