public bool TestingOnly()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(447412218887);
            recipients.AddRecipient(447412218887);
            var Message = new Message("RCS", "Hello from Rizwan", recipients);

            var responseMessage = SendMessage(Message);

            return(responseMessage);
        }
Ejemplo n.º 2
0
        public void OriginatorFormat()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);

            new Message("Orignator", "This is a message from an originator", recipients);
            var message = new Message("Or igna tor", "This is a message from an originator with whitespace", recipients);

            try
            {
                message = new Message("Orignator ", "This is a message from an originator with trailing whitespace", recipients);
                Assert.Fail("Expected an error exception, because the originator contains trailing whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            try
            {
                message = new Message(" Orignator", "This is a message from an originator with leading whitespace", recipients);
                Assert.Fail("Expected an error exception, because the originator contains leading whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }
        }
Ejemplo n.º 3
0
        public void OriginatorFormat()
        {
            //https://developers.messagebird.com/docs/messaging
            //ORIGINATOR The sender of the message. This can be a telephone number (including country code) or an alphanumeric string.
            //In case of an alphanumeric string, the maximum length is 11 characters.

            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);

            var message = new Message("Originator", "This is a message from a valid originator with less or equal than 11 alphanumeric characters.", recipients);

            Assert.AreEqual("Originator", message.Originator);

            message = new Message("3197001234567890", "This is a message from a valid originator with numeric characters.", recipients);
            Assert.AreEqual("3197001234567890", message.Originator);

            message = new Message("Or igna t0r", "This is a message from a valid originator with alphanumeric characters and whitespaces and less or equal than 11 characters.", recipients);
            Assert.AreEqual("Or igna t0r", message.Originator);

            try
            {
                message = new Message("Originator ", "This is a message from an invalid originator with trailing whitespace.", recipients);
                Assert.Fail("Expected an exception, because the originator contains trailing whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Originator can only contain numeric or whitespace separated alphanumeric characters.", e.Message);
            }

            try
            {
                message = new Message(" Originator", "This is a message from an inavlid originator with leading whitespace.", recipients);
                Assert.Fail("Expected an exception, because the originator contains leading whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Originator can only contain numeric or whitespace separated alphanumeric characters.", e.Message);
            }

            try
            {
                message = new Message("OriginatorXL", "This is a message from an invalid originator with more than 11 alphanumeric characters.", recipients);
                Assert.Fail("Expected an exception, because the originator has more than 11 alphanumeric characters.");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Alphanumeric originator is limited to 11 characters.", e.Message);
            }
        }
Ejemplo n.º 4
0
        public void DeserializeRecipientsAsMsisdnsArray()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);

            var message  = new Message("MsgBirdSms", "Welcome to MessageBird", recipients);
            var messages = new Messages(message);

            string serializedMessage = messages.Serialize();

            messages.Deserialize(serializedMessage);
        }
        public void DeserializeRecipientsAsMsisdnsArray()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);

            var voiceMessage  = new VoiceMessage("Welcome to MessageBird", recipients);
            var voiceMessages = new VoiceMessages(voiceMessage);

            string serializedMessage = voiceMessages.Serialize();

            voiceMessages.Deserialize(serializedMessage);
        }
Ejemplo n.º 6
0
        public void ReportUrl()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);
            var optionalArguments = new MessageOptionalArguments
            {
                ReportUrl = "https://example.com/status-update",
            };

            var message = new Message("Originator", "Body", recipients, optionalArguments);

            Assert.AreEqual("https://example.com/status-update", message.ReportUrl);
        }
        public void ReportUrl()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);
            var optionalArguments = new VoiceMessageOptionalArguments
            {
                ReportUrl = "https://example.com/voice-status",
            };

            var voiceMessage = new VoiceMessage("Body", recipients, optionalArguments);

            Assert.AreEqual(voiceMessage.ReportUrl, "https://example.com/voice-status");
        }
        public void ReportUrl()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);
            var optionalArguments = new MessageOptionalArguments
            {
                ReportUrl = "https://localhost:8080",
            };

            var message = new Message("Provider", "Body", recipients, optionalArguments);

            Assert.AreEqual("https://localhost:8080", message.ReportUrl);
        }
        public void OriginatorFormat()
        {
            var recipients = new Recipients();

            recipients.AddRecipient(31612345678);

            var message = new Message("Provider", "This is a message with less or equal than 11 alphanumeric characters.", recipients);

            Assert.AreEqual("Provider", message.Originator);

            message = new Message("321321321321", "This is a message with numeric characters.", recipients);
            Assert.AreEqual("3197001234567890", message.Originator);

            message = new Message("Hell0 Dünya", "This is a message with alphanumeric characters and whitespaces and less or equal than 11 characters.", recipients);
            Assert.AreEqual("Or igna t0r", message.Originator);

            try
            {
                message = new Message("Pr0 vider ", "This is a message from an invalid provider with trailing whitespace.", recipients);
                Assert.Fail("Expected an exception, because the originator contains trailing whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Provider can only contain numeric or whitespace separated alphanumeric characters.", e.Message);
            }

            try
            {
                message = new Message(" Provider", "This is a message from an inavlid originator with leading whitespace.", recipients);
                Assert.Fail("Expected an exception, because the originator contains leading whitespace!");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Provider can only contain numeric or whitespace separated alphanumeric characters.", e.Message);
            }

            try
            {
                message = new Message("ProviderXL", "This is a message from an invalid originator with more than 11 alphanumeric characters.", recipients);
                Assert.Fail("Expected an exception, because the originator has more than 11 alphanumeric characters.");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
                Assert.AreEqual("Alphanumeric provider is limited to 11 characters.", e.Message);
            }
        }