示例#1
0
        public void Send()
        {
            //Create entity
            Twizo twizo = new Twizo(this.apiKey, this.apiHost);
            var   sms   = twizo.CreateSms(this.recipients, this.body, this.sender);

            sms.resultType = 2;

            //Set variables
            if (this.senderTon >= 0)
            {
                sms.senderTon = this.senderTon;
            }
            if (this.senderNpi >= 0)
            {
                sms.senderNpi = this.senderNpi;
            }
            if (this.pid >= 0)
            {
                sms.pid = this.pid;
            }
            //sms.scheduledDelivery = this.scheduledDelivery.ToString("yyyy-MM-ddTHH:mm:ssZ");
            if (this.tag != "")
            {
                sms.tag = this.tag;
            }
            sms.validity = this.validity;
            if (this.resultType >= 0)
            {
                sms.resultType = this.resultType;
            }
            if (this.callbackUrl != "")
            {
                sms.callbackUrl = this.callbackUrl;
            }

            if (this.dcs >= 0)
            {
                sms.dcs = this.dcs;
            }
            if (this.udh != "")
            {
                sms.udh = this.udh;
            }

            //Send
            sms.Send();

            //Log
            LogResponse(sms);
            this.messageId = sms.messageId;
        }
示例#2
0
        public void CreateSmsTestNull()
        {
            //Arrange
            string recipient = null;
            string body      = "This is a unit test";
            string sender    = "Unit tester";
            Twizo  twizo     = new Twizo(apiKey, apiHost);

            //Act
            var sms = twizo.CreateSms(recipient, body, sender);

            //Assert
            Assert.AreEqual(sms.recipient, recipient);
            Assert.AreEqual(sms.body, body);
            Assert.AreEqual(sms.sender, sender);
        }
示例#3
0
        public void GetSmsTest()
        {
            //Arrange
            string recipient = "601151174973";
            string body      = "This is a unit test";
            string sender    = "Unit tester";
            Twizo  twizo     = new Twizo(apiKey, apiHost);

            //Act
            var sms = twizo.CreateSms(recipient, body, sender);

            sms.Send();
            string messageId = sms.messageId;
            var    newSms    = twizo.GetSms(messageId);

            //Assert
            Assert.AreEqual(sms.messageId, newSms.messageId);
            Assert.AreEqual(sms.recipient, newSms.recipient);
        }