public void PacketStreamWriteWhenReadOnlyTest() { using (ILitePacketStream packetStream = new LitePacketStream(_randomizer.Bytes(_randomizer.Byte()))) { Assert.Throws <InvalidOperationException>(() => packetStream.Write <byte>(_randomizer.Byte())); } }
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); } }
public void PacketStreamWriteNonPrimitiveTest() { using ILitePacketStream packetStream = new LitePacketStream(); Assert.Throws <NotImplementedException>(() => packetStream.Write <object>(new object())); }