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));
            }
        }
        public VoiceMessage SendVoiceMessage(string body, long[] msisdns, VoiceMessageOptionalArguments optionalArguments = null)
        {
            ParameterValidator.IsNotNullOrWhiteSpace(body, "body");
            ParameterValidator.ContainsAtLeast(msisdns, 1, "msisdns");

            var recipients = new Recipients(msisdns);
            var voiceMessage = new VoiceMessage(body, recipients, optionalArguments);
            var voiceMessages = new VoiceMessages(voiceMessage);
            var result = restClient.Create(voiceMessages);

            return result.Object as VoiceMessage;
        }
        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);
        }
        public Message SendMessage(string originator, string body, long[] msisdns, MessageOptionalArguments optionalArguments = null)
        {
            ParameterValidator.IsNotNullOrWhiteSpace(originator, "originator");
            ParameterValidator.IsNotNullOrWhiteSpace(body, "body");
            ParameterValidator.ContainsAtLeast(msisdns, 1, "msisdns");

            var recipients = new Recipients(msisdns);
            var message = new Message(originator, body, recipients, optionalArguments);

            var messages = new Messages(message);
            var result = restClient.Create(messages);

            return result.Object as Message;
        }
        public void DeserializeAndSerialize()
        {
            const string CreateMessageResponseTemplate = @"{
              'id':'e7028180453e8a69d318686b17179500',
              'href':'https:\/\/rest.messagebird.com\/messages\/e7028180453e8a69d318686b17179500',
              'direction':'mt',
              'type':'sms',
              'originator':'$ORIGINATOR',
              'body':'Welcome to MessageBird',
              'reference':null,
              'validity':null,
              'gateway':56,
              'typeDetails':{

              },
              'datacoding':'plain',
              'mclass':1,
              'scheduledDatetime':null,
              'createdDatetime':'2014-08-11T11:18:53+00:00',
              'recipients':{
            'totalCount':1,
            'totalSentCount':1,
            'totalDeliveredCount':0,
            'totalDeliveryFailedCount':0,
            'items':[
              {
            'recipient':31612345678,
            'status':'sent',
            'statusDatetime':'2014-08-11T11:18:53+00:00'
              }
            ]
              }
            }";
            Recipients recipients = new Recipients();
            Message message = new Message("", "", recipients);
            Messages messages = new Messages(message);

            messages.Deserialize(CreateMessageResponseTemplate.Replace("$ORIGINATOR", "Messagebird"));
            JsonConvert.DeserializeObject<Message>(messages.Object.ToString());

            messages.Deserialize(CreateMessageResponseTemplate.Replace("$ORIGINATOR", "3112345678"));
            JsonConvert.DeserializeObject<Message>(messages.Object.ToString());

            messages.Deserialize(CreateMessageResponseTemplate.Replace("$ORIGINATOR", "+3112345678"));
            JsonConvert.DeserializeObject<Message>(messages.Object.ToString());
        }
        public void DeserializeAndSerialize()
        {
            const string JsonResultFromCreateVoiceMessageExample = @"{
              'id':'955c3130353eb3dcd090294a42643365',
              'href':'https:\/\/rest.messagebird.com\/voicemessages\/955c3130353eb3dcd090294a42643365',
              'body':'This is a test message. The message is converted to speech and the recipient is called on his mobile.',
              'reference':null,
              'language':'en-gb',
              'voice':'female',
              'repeat':1,
              'ifMachine':'continue',
              'scheduledDatetime':null,
              'createdDatetime':'2014-08-13T10:28:29+00:00',
              'recipients':{
            'totalCount':1,
            'totalSentCount':1,
            'totalDeliveredCount':0,
            'totalDeliveryFailedCount':0,
            'items':[
              {
            'recipient':31612345678,
            'status':'calling',
            'statusDatetime':'2014-08-13T10:28:29+00:00'
              }
            ]
              }
            }";
            var recipients = new Recipients();
            var voiceMessage = new VoiceMessage("", recipients);
            var voiceMessages = new VoiceMessages(voiceMessage);
            voiceMessages.Deserialize(JsonResultFromCreateVoiceMessageExample);

            var voiceMessageResult = voiceMessages.Object as VoiceMessage;

            string voiceMessageResultString = voiceMessageResult.ToString();

            JsonConvert.DeserializeObject<VoiceMessage>(voiceMessageResultString); // check if Deserialize/Serialize cycle works.
        }