예제 #1
0
        public void SerializationIsSymmetric()
        {
            var buffer = new ArrayBufferWriter <Byte>();
            var value  = RandomSubject;

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

            Assert.Equal(expected: value.ConsumerCount, actual: deserialized.ConsumerCount);
            Assert.Equal(expected: value.MessageCount, actual: deserialized.MessageCount);
            Assert.Equal(expected: value.QueueName, actual: deserialized.QueueName);
        }
예제 #2
0
        public void DeserializationReturnsSurplusData()
        {
            var value  = RandomSubject;
            var extra  = Random.UInt();
            var buffer = new ArrayBufferWriter <Byte>();

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

            QueueDeclareOk.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));
        }
예제 #3
0
        public void DeserializationFailsWithInsufficientData()
        {
            var result = QueueDeclareOk.Deserialize(new Byte[0], out var _, out var _);

            Assert.False(result);
        }