public void NotIncludeEntriesOver1DayOld() { var entries = TestEntries(); var spec = new GuestbookNotificationPolicy(entries.First().Id); var entriesToNotify = entries.Where(spec.Criteria.Compile()); Assert.True(entriesToNotify.Where(x => x.Id == 1).Count() == 0); }
public void NotIncludeEntriesOver1DayOld() { var entries = TestEntries(); var spec = new GuestbookNotificationPolicy(1); var entriesToNotify = entries.Where(spec.Criteria.Compile()); Assert.DoesNotContain(entriesToNotify, e => e.Id == 4); }
public void IncludeEntriesFromLast24Hours() { var entries = TestEntries(); var spec = new GuestbookNotificationPolicy(entries.First().Id); var entriesToNotify = entries.Where(spec.Criteria.Compile()); Assert.Equal(1, entriesToNotify.Count()); }
public void IncludeEntriesFromLast24Hours() { var entries = TestEntries(); var spec = new GuestbookNotificationPolicy(1); var entriesToNotify = entries.Where(spec.Criteria.Compile()).ToList(); Assert.NotNull(entriesToNotify.SingleOrDefault(e => e.Id == 2)); Assert.NotNull(entriesToNotify.SingleOrDefault(e => e.Id == 3)); }
public void Handle(EntryAddedEvent entryAddedEvent) { var notificationPolicy = new GuestbookNotificationPolicy(entryAddedEvent.Entry.Id); var emailsToNotify = repository.List(notificationPolicy).Select(e => e.EmailAddress); foreach (var emailAddress in emailsToNotify) { string messageBody = $"{emailAddress} left a new message {entryAddedEvent.Entry.Message}"; messageSender.SendGuestBookNotificationEmail(emailAddress, messageBody); } }
public void Handle(EntryAddedEvent domainEvent) { var gbnotificationpolicy = new GuestbookNotificationPolicy(domainEvent.Entry.Id); var emailsToNotify = _repo.List(gbnotificationpolicy).Select(e => e.EmailAddress); foreach (var email in emailsToNotify) { string messageBody = $"{domainEvent.Entry.EmailAddress} left a new message {domainEvent.Entry.Message}"; _messageSender.SendGuestbookNotificationEmail(email, messageBody); } }
public void Handle(EntryAddedEvent entryAddedEvent) { var notificationPolicy = new GuestbookNotificationPolicy(entryAddedEvent.Entry.Id); // send updates to previous entries made in the last day var emailsToNotify = _repository.List(notificationPolicy).Select(e => e.EmailAddress); foreach (var emailAddress in emailsToNotify) { string messageBody = $"{entryAddedEvent.Entry.EmailAddress} left a new message {entryAddedEvent.Entry.Message}."; _messageSender.SendGuestbookNotificationEmail(emailAddress, messageBody); } }
public GuestBookNotificationPolicyShould() { notificationPolicy = new GuestbookNotificationPolicy(1); }