Ejemplo n.º 1
0
        public void Create_FromIsNull_ThrowsArgumentNullException()
        {
            var argumentExceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings("accountSid", "apiToken", null));
            }
            catch (ArgumentNullException)
            {
                argumentExceptionThrown = true;
            }

            Assert.IsTrue(argumentExceptionThrown);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var title   = "Test message title";
            var message = "Test message text";

            IEzGateway smsGateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioConstants.AccountSid, TwilioConstants.ApiToken, TwilioConstants.SenderPhoneNumber));

            smsGateway.SendMessage("PUT_A_VALID_PHONE_NUMBER_HERE", message);

            IEzGateway mailGateway = GmailGateway.Create(new GmailSettings(new MailAddress(GmailConstants.SenderEmailAddress, GmailConstants.SenderAlias), GmailConstants.SenderEmailAddress, GmailConstants.SenderPassword));

            mailGateway.SendMessage("PUT_A_VALID_EMAIL_ADDRESS_HERE", message, title);

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public void SendMessage_ApiTokenInvalid_ThrowsException()
        {
            var exceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioTestConstants.AccountSid, "apiToken", TwilioTestConstants.SenderPhoneNumber));
                gateway.SendMessage(TwilioTestConstants.RecipientPhoneNumber, $"Testing {nameof(SendMessage_ApiTokenInvalid_ThrowsException)}");
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 4
0
        public void SendMessage_InputsAreValid_ThrownsNoExceptions()
        {
            var exceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioTestConstants.AccountSid, TwilioTestConstants.ApiToken, TwilioTestConstants.SenderPhoneNumber));
                gateway.SendMessage(TwilioTestConstants.RecipientPhoneNumber, $"Testing {nameof(SendMessage_InputsAreValid_ThrownsNoExceptions)}");
            }
            catch (ArgumentOutOfRangeException)
            {
                exceptionThrown = true;
            }

            Assert.IsFalse(exceptionThrown);
        }
Ejemplo n.º 5
0
        public void SendMessage_TooLongMessage_ThrowsArgumentOutOfRangeException()
        {
            var argumentOutOfRangeExceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioTestConstants.AccountSid, TwilioTestConstants.ApiToken, TwilioTestConstants.SenderPhoneNumber));
                gateway.SendMessage(TwilioTestConstants.RecipientPhoneNumber, new string('x', 1601));
            }
            catch (ArgumentOutOfRangeException)
            {
                argumentOutOfRangeExceptionThrown = true;
            }

            Assert.IsTrue(argumentOutOfRangeExceptionThrown);
        }
Ejemplo n.º 6
0
        public void SendMessage_MessageTextIsNull_ThrowsArgumentNullException()
        {
            var argumentNullExceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioTestConstants.AccountSid, TwilioTestConstants.ApiToken, TwilioTestConstants.SenderPhoneNumber));
                gateway.SendMessage(TwilioTestConstants.RecipientPhoneNumber, null);
            }
            catch (ArgumentNullException)
            {
                argumentNullExceptionThrown = true;
            }

            Assert.IsTrue(argumentNullExceptionThrown);
        }
Ejemplo n.º 7
0
        public void SendMessage_RecipientIsInvalid_ThrowsException()
        {
            var exceptionThrown = false;

            try
            {
                var gateway = TwilioSmsGateway.Create(new TwilioSettings(TwilioTestConstants.AccountSid, TwilioTestConstants.ApiToken, TwilioTestConstants.SenderPhoneNumber));
                gateway.SendMessage("THISISNOTAREALPHONENUMBER", "messageText");
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }