Sha256: edd6ba8912af06dc697ef5471d74a31192827ecb9ae6b728068fcc07655d528a

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'test/unit'

require_relative '../lib/messagemedia/soap/recipient'
require_relative '../lib/messagemedia/soap/message'

class TestMessage < Test::Unit::TestCase

  def test_to_api_hash
    message = Messagemedia::SOAP::Message.new

    # First test recipient, with a custom message ID
    message_id_1 = 100
    recipient_1 = 123456
    message.add_recipient(message_id_1, recipient_1)

    # Second test recipient, no message ID
    recipient_2 = 456789
    message.add_recipient(nil, recipient_2)

    expected_hash = {
        :'@format' => message.format,
        :'@sequenceNumber' => message.sequence_number,
        :'api:deliveryReport' => message.delivery_report,
        :'api:validityPeriod' => message.validity_period,
        :'api:content' => message.content,
        :'api:recipients' => {
            :'api:recipient' => [
                recipient_1,
                recipient_2
            ],
            :attributes! => {
                :'api:recipient' => {
                    :uid => [
                        message_id_1,
                        nil
                    ]
                }
            }
        }
    }

    assert_equal(expected_hash, message.to_api_hash)

  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
messagemedia-soap-0.6.8.1 test/test_message.rb
messagemedia-soap-0.6.8 test/test_message.rb
messagemedia-ruby-0.7.0 test/test_message.rb
messagemedia-soap-0.6.7 test/test_message.rb