示例#1
0
        public void Scheduled_Message_Is_Canceled()
        {
            // Setup
            var    apiKey    = ConfigurationManager.AppSettings["APIKey"];
            string toEmail   = ConfigurationManager.AppSettings["ValidToEmail"];
            string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

            // Exercise
            var api = new MandrillApi(apiKey);

            var messages = api.SendMessage(new EmailMessage
            {
                to =
                    new List <EmailAddress> {
                    new EmailAddress {
                        email = toEmail, name = ""
                    }
                },
                from_email = fromEmail,
                subject    = "Mandrill Integration Test",
                html       = "<strong>Scheduled Email</strong>",
                text       = "Example text"
            }, DateTime.UtcNow.AddMinutes(5.0));

            var scheduled = api.ListScheduledMessages(toEmail);

            //Verify that message was scheduled
            Assert.AreEqual(1, scheduled.Count(s => s.Id == messages.First().Id));

            api.CancelScheduledMessage(messages.First().Id);
            scheduled = api.ListScheduledMessages(toEmail);

            //Verify that message was cancelled.
            Assert.AreEqual(0, scheduled.Count(s => s.Id == messages.First().Id));
        }
示例#2
0
        public void Scheduled_Message_Is_Rescheduled()
        {
            // Setup
            var    apiKey    = ConfigurationManager.AppSettings["APIKey"];
            string toEmail   = ConfigurationManager.AppSettings["ValidToEmail"];
            string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

            // Exercise
            var api = new MandrillApi(apiKey);

            var messages = api.SendMessage(new EmailMessage
            {
                to =
                    new List <EmailAddress> {
                    new EmailAddress {
                        email = toEmail, name = ""
                    }
                },
                from_email = fromEmail,
                subject    = "Mandrill Integration Test",
                html       = "<strong>Scheduled Email</strong>",
                text       = "Example text"
            }, DateTime.UtcNow.AddMinutes(5.0));

            var message = api.ListScheduledMessages().Find(s => s.Id == messages.First().Id);

            var rescheduled = api.RescheduleMessage(message.Id, message.SendAt.AddMinutes(5.0));

            //Verify
            Assert.Greater(rescheduled.SendAt, message.SendAt);

            //Tear down
            api.CancelScheduledMessage(rescheduled.Id);
        }
示例#3
0
        public async Task Should_Schedule_Then_List_Scheduled_And_Cancel_Message()
        {
            if (!IsPaidAccount)
            {
                Assert.Ignore("Not a paid account");
            }
            // Setup
            string apiKey    = ConfigurationManager.AppSettings["APIKey"];
            string toEmail   = ConfigurationManager.AppSettings["ValidToEmail"];
            string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

            // Exercise
            var api = new MandrillApi(apiKey);

            List <EmailResult> result = await api.SendMessage(new SendMessageRequest(new EmailMessage
            {
                To =
                    new List <EmailAddress> {
                    new EmailAddress {
                        Email = toEmail, Name = ""
                    }
                },
                FromEmail = fromEmail,
                Subject = "Mandrill Integration Test",
                Html = "<strong>Example HTML</strong>",
                Text = "Example text"
            }){
                SendAt = DateTime.Now.AddMinutes(5)
            });

            List <ScheduledEmailResult> scheduled =
                await api.ListScheduledMessages(new ListScheduledMessagesRequest { ToEmail = toEmail });

            //Verify that message was scheduled
            Assert.AreEqual(1, scheduled.Count(s => s.Id == result.First().Id));

            await api.CancelScheduledMessage(new CancelScheduledMessageRequest(result.First().Id));

            scheduled = await api.ListScheduledMessages(new ListScheduledMessagesRequest { ToEmail = toEmail });

            //Verify that message was canceled.
            Assert.AreEqual(0, scheduled.Count(s => s.Id == result.First().Id));
        }
    public async Task Should_Schedule_Then_List_Scheduled_And_Cancel_Message()
    {
      if (!IsPaidAccount)
        Assert.Ignore("Not a paid account");
      // Setup
      string apiKey = ConfigurationManager.AppSettings["APIKey"];
      string toEmail = ConfigurationManager.AppSettings["ValidToEmail"];
      string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

      // Exercise
      var api = new MandrillApi(apiKey);

      List<EmailResult> result = await api.SendMessage(new SendMessageRequest(new EmailMessage
        {
          To =
            new List<EmailAddress> {new EmailAddress {Email = toEmail, Name = ""}},
          FromEmail = fromEmail,
          Subject = "Mandrill Integration Test",
          Html = "<strong>Example HTML</strong>",
          Text = "Example text"
        }){
        SendAt = DateTime.Now.AddMinutes(5)
      });

      List<ScheduledEmailResult> scheduled =
        await api.ListScheduledMessages(new ListScheduledMessagesRequest {ToEmail = toEmail});

      //Verify that message was scheduled
      Assert.AreEqual(1, scheduled.Count(s => s.Id == result.First().Id));

      await api.CancelScheduledMessage(new CancelScheduledMessageRequest(result.First().Id));
      scheduled = await api.ListScheduledMessages(new ListScheduledMessagesRequest {ToEmail = toEmail});

      //Verify that message was canceled.
      Assert.AreEqual(0, scheduled.Count(s => s.Id == result.First().Id));
    }
        public void Scheduled_Message_Is_Rescheduled()
        {
            // Setup
            var apiKey = ConfigurationManager.AppSettings["APIKey"];
            string toEmail = ConfigurationManager.AppSettings["ValidToEmail"];
            string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

            // Exercise
            var api = new MandrillApi(apiKey);

            var messages = api.SendMessage(new EmailMessage
                {
                    to =
                        new List<EmailAddress> { new EmailAddress { email = toEmail, name = "" } },
                    from_email = fromEmail,
                    subject = "Mandrill Integration Test",
                    html = "<strong>Scheduled Email</strong>",
                    text = "Example text"
                }, DateTime.UtcNow.AddMinutes(5.0));

            var message = api.ListScheduledMessages().Find(s => s.Id == messages.First().Id);

            var rescheduled = api.RescheduleMessage(message.Id, message.SendAt.AddMinutes(5.0));

            //Verify
            Assert.Greater(rescheduled.SendAt, message.SendAt);

            //Tear down
            api.CancelScheduledMessage(rescheduled.Id);
        }
        public void Scheduled_Message_Is_Canceled()
        {
            // Setup
            var apiKey = ConfigurationManager.AppSettings["APIKey"];
            string toEmail = ConfigurationManager.AppSettings["ValidToEmail"];
            string fromEmail = ConfigurationManager.AppSettings["FromEMail"];

            // Exercise
            var api = new MandrillApi(apiKey);

            var messages = api.SendMessage(new EmailMessage
            {
                to =
                    new List<EmailAddress> { new EmailAddress { email = toEmail, name = "" } },
                from_email = fromEmail,
                subject = "Mandrill Integration Test",
                html = "<strong>Scheduled Email</strong>",
                text = "Example text"
            }, DateTime.UtcNow.AddMinutes(5.0));

            var scheduled = api.ListScheduledMessages(toEmail);

            //Verify that message was scheduled
            Assert.AreEqual(1, scheduled.Count(s => s.Id == messages.First().Id));

            api.CancelScheduledMessage(messages.First().Id);
            scheduled = api.ListScheduledMessages(toEmail);

            //Verify that message was cancelled.
            Assert.AreEqual(0, scheduled.Count(s => s.Id == messages.First().Id));
        }