fn test_empty_message_serialization()

in sdk/core/azure_core_amqp/src/messaging.rs [1706:1757]


    fn test_empty_message_serialization() {
        {
            let message = AmqpMessage::builder().build();
            let serialized = AmqpMessage::serialize(&message).unwrap();
            assert_eq!(serialized, vec![0, 0x53, 0x77, 0x40]);
            #[cfg(all(feature = "fe2o3_amqp", not(target_arch = "wasm32")))]
            {
                // Verify that the serialization of an AmqpMessage with no body matches
                // the fe2o3_amqp serialization.
                let body_type: fe2o3_amqp_types::messaging::Body<()> =
                    fe2o3_amqp_types::messaging::Body::Empty;
                let amqp_message = fe2o3_amqp_types::messaging::message::Builder::new()
                    .body(body_type)
                    .build();
                let serialized_fe2o3 = serde_amqp::ser::to_vec(
                    &fe2o3_amqp_types::messaging::message::__private::Serializable(amqp_message),
                )
                .unwrap();
                assert_eq!(serialized, serialized_fe2o3);
            }
        }
        {
            let message = AmqpMessage::builder()
                .with_header(AmqpMessageHeader {
                    time_to_live: (Some(std::time::Duration::from_millis(23))),
                    ..Default::default()
                })
                .build();
            let serialized = AmqpMessage::serialize(&message).unwrap();

            // The serialized body should contain:
            // - 0x0 DESCRIPTOR
            // - 0x53 // smallulong
            // - 0x70: MESSAGE HEADER
            // - 0xc0: 0 (COMPOUND LIST)
            // - 0x5: 5 (WIDTH 5 bytes)
            // - 0x3: 3 (LENGTH 3 items)
            // - 0x40: (ITEM 0 - Durable - EMPTY)
            // - 0x40: (ITEM 1 - Priority - EMPTY)
            // - 0x52: (ITEM 2 - Time to Live - SMALLUINT)
            // - 23: 23 Time To Live == 23.
            // - 0x00: 0 DESCRIPTOR
            // - 0x53: SMALLULONG
            // - 0x77: AMQP VALUE BODY
            // - 0x40: EMPTY

            assert_eq!(
                serialized,
                vec![0, 0x53, 0x70, 0xc0, 0x5, 0x3, 0x40, 0x40, 0x52, 23, 0x00, 0x53, 0x77, 0x40]
            );
        }
    }