From c0ebbf6b52c718a7a4167220969fbfe31e38051d Mon Sep 17 00:00:00 2001 From: Nicholas Rempel Date: Wed, 5 Jan 2022 11:48:41 -0800 Subject: [PATCH] Add test case for message only poll response --- src/message/poll.rs | 28 +++++++++++++++++++ .../response/message/poll_message_only.xml | 19 +++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/resources/response/message/poll_message_only.xml diff --git a/src/message/poll.rs b/src/message/poll.rs index 3d48034..bf6e8ec 100644 --- a/src/message/poll.rs +++ b/src/message/poll.rs @@ -149,6 +149,34 @@ mod tests { assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); } + #[test] + fn message_only_response() { + let xml = get_xml("response/message/poll_message_only.xml").unwrap(); + let object = MessagePoll::deserialize_response(xml.as_str()).unwrap(); + + let msg = object.message_queue().unwrap(); + + assert_eq!(object.result.code, 1301); + assert_eq!( + object.result.message, + "Command completed successfully; ack to dequeue".into() + ); + + assert_eq!(msg.count, 4); + assert_eq!(msg.id, "12346".to_string()); + assert_eq!( + *(msg.date.as_ref().unwrap()), + "2000-06-08T22:10:00.0Z".into() + ); + assert_eq!( + *(msg.message.as_ref().unwrap()), + "Credit balance low.".into() + ); + + assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); + assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); + } + #[test] fn empty_queue_response() { let xml = get_xml("response/message/poll_empty_queue.xml").unwrap(); diff --git a/tests/resources/response/message/poll_message_only.xml b/tests/resources/response/message/poll_message_only.xml new file mode 100644 index 0000000..55e68e6 --- /dev/null +++ b/tests/resources/response/message/poll_message_only.xml @@ -0,0 +1,19 @@ + + + + + Command completed successfully; ack to dequeue + + + 2000-06-08T22:10:00.0Z + Credit balance low. + 100 + 5 + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file