public void SerializationIsSymmetric()
        {
            var buffer = new ArrayBufferWriter <Byte>();
            var value  = RandomSubject;

            value.Serialize(buffer);
            BasicCancelOk.Deserialize(buffer.WrittenMemory.Span, out var deserialized, out var _);

            Assert.Equal(expected: value.ConsumerTag, actual: deserialized.ConsumerTag);
        }
        public void DeserializationReturnsSurplusData()
        {
            var value  = RandomSubject;
            var extra  = Random.UInt();
            var buffer = new ArrayBufferWriter <Byte>();

            buffer.WriteSerializable(value)
            .WriteUInt32LE(extra);

            BasicCancelOk.Deserialize(buffer.WrittenMemory.Span, out var _, out var surplus);

            Assert.Equal(expected: sizeof(UInt32), actual: surplus.Length);
            Assert.Equal(expected: extra, actual: BitConverter.ToUInt32(surplus));
        }
        public void UnwrapsBasicCancelOkMethodFrame()
        {
            var message = new BasicCancelOk(
                consumerTag: Random.Word()
                );

            _context.Send(_subject, (Inbound, RawFrame.Wrap(_channelNumber, message)));

            if (_messageReceivedSignal.Wait(timeout: TimeSpan.FromMilliseconds(100)))
            {
                var unwrappedMessage = _unwrappedMessage as BasicCancelOk;

                Assert.Equal(expected: message.ConsumerTag, actual: unwrappedMessage.ConsumerTag);
            }
            else
            {
                // No `BasicCancelOk` command was received within 100 millis...
                throw new TimeoutException("Timeout occurred before command was received");
            }
        }
        public void DeserializationFailsWithInsufficientData()
        {
            var result = BasicCancelOk.Deserialize(new Byte[0], out var _, out var _);

            Assert.False(result);
        }