Beispiel #1
0
        public void Build_Simple_WithMessageId_Callback_SendTime_Test()
        {
            var builder = new SendMessagesRequestBuilder();

            var result = builder.BuildPostXmlData(new List <ISmsMessage>()
            {
                new SmsMessage(messageId: "MessageId123",
                               msisdn: "4511111111",
                               text: "Text msg 1",
                               senderName: "SenderA",
                               encoding: SmsEncoding.Utf8,
                               sendTime: new DateTime(2001, 02, 03, 04, 05, 06))
            },
                                                  "apiKey",
                                                  "http://someUrl.callback.inmobile.dk/unittest/messagestatus");

            var expectedOutput =
                $@"<request source=""Official SendMessages Client {ClientUtils.VersionNumber}"">
  <authentication apikey=""apiKey"" />
  <data>
    <statuscallbackurl>http://someUrl.callback.inmobile.dk/unittest/messagestatus</statuscallbackurl>
    <message>
      <sendername>SenderA</sendername>
      <text encoding=""utf-8"" flash=""false"">Text msg 1</text>
      <recipients>
        <msisdn id=""MessageId123"">4511111111</msisdn>
      </recipients>
      <sendtime>2001-02-03 04:05:06</sendtime>
    </message>
  </data>
</request>";

            AssertEqualXml(expectedOutput, result);
        }
Beispiel #2
0
        public void Build_RefundMessages_Test()
        {
            var builder = new SendMessagesRequestBuilder();

            var refund1 = new RefundMessage(messageIdToRefund: "RefundId1", messageText: "Refund & < > text 1", messageId: "MessageId123");
            var refund2 = new RefundMessage(messageIdToRefund: "RefundId2", messageText: "Refund text 2");

            var result = builder.BuildPostXmlData(new List <ISmsMessage>()
            {
                refund1, refund2
            }, "apiKey", "http://someUrl.callback.inmobile.dk/unittest/messagestatus");

            var expectedOutput =
                $@"<request source=""Official SendMessages Client {ClientUtils.VersionNumber}"">
  <authentication apikey=""apiKey"" />
  <data>
    <statuscallbackurl>http://someUrl.callback.inmobile.dk/unittest/messagestatus</statuscallbackurl>
    <refundmessage messageidtorefund=""RefundId1"" messageid=""MessageId123"">
      <text>Refund &amp; &lt; &gt; text 1</text>
    </refundmessage>
    <refundmessage messageidtorefund=""RefundId2"">
      <text>Refund text 2</text>
    </refundmessage>
  </data>
</request>";

            AssertEqualXml(expectedOutput, result);
        }
Beispiel #3
0
        public void Build_Simple_WithRespectBlacklistingToFalse_Test()
        {
            var builder = new SendMessagesRequestBuilder();

            var result = builder.BuildPostXmlData(new List <ISmsMessage>()
            {
                new SmsMessage(msisdn: "4511111111",
                               text: "Text msg 1",
                               senderName: "SenderA",
                               encoding: SmsEncoding.Utf8,
                               respectBlacklist: false)
            },
                                                  "apiKey",
                                                  messageStatusCallbackUrl: null);

            var expectedOutput =
                $@"<request source=""Official SendMessages Client {ClientUtils.VersionNumber}"">
  <authentication apikey=""apiKey"" />
  <data>
    <message>
      <sendername>SenderA</sendername>
      <text encoding=""utf-8"" flash=""false"">Text msg 1</text>
      <recipients>
        <msisdn>4511111111</msisdn>
      </recipients>
      <respectblacklist>false</respectblacklist>
    </message>
  </data>
</request>";

            AssertEqualXml(expectedOutput, result);
        }
Beispiel #4
0
        public void Build_Overcharged_Test()
        {
            var builder = new SendMessagesRequestBuilder();

            var message = new SmsMessage(messageId: "MessageId123",
                                         msisdn: "4511111111",
                                         text: "Text msg 1",
                                         senderName: "SenderA",
                                         encoding: SmsEncoding.Utf8);

            message.OverchargeInfo = new OverchargeInfo(overchargeType: OverchargeType.MobilePayment, overchargePrice: 2500, shortCodeCountryCode: "45", shortCodeNumber: "1245", invoiceDescription: "Some description");
            var result = builder.BuildPostXmlData(new List <ISmsMessage>()
            {
                message
            }, "apiKey", "http://someUrl.callback.inmobile.dk/unittest/messagestatus");

            var expectedOutput =
                $@"<request source=""Official SendMessages Client {ClientUtils.VersionNumber}"">
  <authentication apikey=""apiKey"" />
  <data>
    <statuscallbackurl>http://someUrl.callback.inmobile.dk/unittest/messagestatus</statuscallbackurl>
    <message>
      <sendername>SenderA</sendername>
      <text encoding=""utf-8"" flash=""false"">Text msg 1</text>
      <recipients>
        <msisdn id=""MessageId123"">4511111111</msisdn>
      </recipients>
      <overchargeinfo price=""2500"" type=""3"" countrycode=""45"" shortcode=""1245"" invoicedescription=""Some description"" />
    </message>
  </data>
</request>";

            AssertEqualXml(expectedOutput, result);
        }