public void DoesNotSendTheSameMeetingsAgain() { var context = new DataContext(null); DataContext.Current = context; context.Meetings.Add(_meeting1); context.Meetings.Add(_meeting2); context.NewsletterSubscriptions.Add(new NewsletterSubscription() { Email = "*****@*****.**", SubscribedToNewMeetingUpdates = true }); context.NewsletterSubscriptions.Add(new NewsletterSubscription() { Email = "*****@*****.**", SubscribedToNewMeetingUpdates = true }); context.NewsletterLogs.Add(new NewsletterLog() { DateSent = DateTime.Now, NewsletterType = typeof(NewMeetingsNewsletter).Name }); var emailAdapter = new EmailAdapterFake(); var handler = new AlertsService(emailAdapter, null); handler.SendNewMeetingsNewsletter(); Assert.Equal(0, emailAdapter.SentEmails.Count); }
public void CheckThatItWillGenerateAndSendCurrectly() { var context = new DataContext(null); DataContext.Current = context; context.Meetings.Add(_meeting1); context.Meetings.Add(_meeting2); context.NewsletterSubscriptions.Add(new NewsletterSubscription() { Email = "*****@*****.**", SubscribedToNewMeetingUpdates = true }); context.NewsletterSubscriptions.Add(new NewsletterSubscription() { Email = "*****@*****.**", SubscribedToNewMeetingUpdates = true }); var emailAdapter = new EmailAdapterFake(); var handler = new AlertsService(emailAdapter, null); handler.SendNewMeetingsNewsletter(); Assert.Equal(2, emailAdapter.SentEmails.Count); var firstEmail = emailAdapter.SentEmails.First(); var lastEmail = emailAdapter.SentEmails.Last(); Assert.Equal(firstEmail.Email, "*****@*****.**"); Assert.Equal(lastEmail.Email, "*****@*****.**"); Assert.Contains("title1", firstEmail.Html); Assert.Contains("title2", firstEmail.Html); Assert.Contains("city1", firstEmail.Html); Assert.Contains("city2", firstEmail.Html); Assert.Contains("ONUG", firstEmail.Html); Assert.Contains("http://geekhub.dk/meetings/1/?utm_source=email", firstEmail.Html); Assert.Contains("http://geekhub.dk/meetings/2/?utm_source=email", firstEmail.Html); // The secound meeting should be the first, as its start date is first Assert.True(firstEmail.Html.IndexOf("title1", System.StringComparison.Ordinal) > firstEmail.Html.IndexOf("title2", System.StringComparison.Ordinal)); Assert.Equal(1, context.NewsletterLogs.Count()); }
public ActionResult SendNewMeetingsNewsletter() { _alertsService.SendNewMeetingsNewsletter(); return(Content("Done")); }