fn test_message_annotation_conversion()

in sdk/core/azure_core_amqp/src/fe2o3/messaging/message_fields.rs [281:329]


fn test_message_annotation_conversion() {
    {
        let annotations = AmqpAnnotations::from(vec![
            (AmqpAnnotationKey::Ulong(1), "test"),
            (AmqpAnnotationKey::Symbol("test".into()), "test"),
        ]);

        let fe2o3_annotations = fe2o3_amqp_types::messaging::Annotations::from(annotations.clone());

        // There does not appear to be a From<OrderedMap<>> for Annotations.
        let mut annotations_to_test = fe2o3_amqp_types::messaging::Annotations::new();
        annotations_to_test.insert(
            fe2o3_amqp_types::messaging::annotations::OwnedKey::Ulong(1),
            "test".into(),
        );
        annotations_to_test.insert(
            fe2o3_amqp_types::messaging::annotations::OwnedKey::Symbol("test".into()),
            "test".into(),
        );
        assert_eq!(fe2o3_annotations, annotations_to_test);

        let amqp_round_trip: AmqpAnnotations = fe2o3_annotations.into();
        assert_eq!(amqp_round_trip, annotations);
    }

    {
        let mut fe2o3_annotations = fe2o3_amqp_types::messaging::Annotations::new();
        fe2o3_annotations.insert(
            fe2o3_amqp_types::messaging::annotations::OwnedKey::Ulong(1),
            "test".into(),
        );
        fe2o3_annotations.insert(
            fe2o3_amqp_types::messaging::annotations::OwnedKey::Symbol("test".into()),
            "test".into(),
        );

        let annotations = AmqpAnnotations::from(fe2o3_annotations.clone());
        assert_eq!(
            annotations,
            AmqpAnnotations::from(vec![
                (AmqpAnnotationKey::Ulong(1), "test"),
                (AmqpAnnotationKey::Symbol("test".into()), "test"),
            ])
        );

        let fe2o3_round_trip: fe2o3_amqp_types::messaging::Annotations = annotations.into();
        assert_eq!(fe2o3_round_trip, fe2o3_annotations);
    }
}