private string getEmailBody(CalendarEvent calendarEvent) { return string.Format( "Notification on {0} Event:\n" + "Title: {1}\n" + "Time: {2}\n" + "Event Text: {3}\n", Enum.GetName(typeof(EventType), calendarEvent.EventType), calendarEvent.Title, getEventTimeString(calendarEvent), calendarEvent.Text); }
private bool eventApproprieteForSend(CalendarEvent calendarEvent) { if (calendarEvent.IsAllDay) return allDayEventRule(calendarEvent); if (calendarEvent.EventType == EventType.Personal) return personalEventRule(calendarEvent); if (calendarEvent.EventType == EventType.Meeting) return meetingEventRule(calendarEvent); return false; }
private string getEventTimeString(CalendarEvent calendarEvent) { if (calendarEvent.IsAllDay) return string.Format("{0} All Day", calendarEvent.DateStart.ToShortDateString()); if (calendarEvent.EventType == EventType.Personal) return calendarEvent.DateStart.ToString(); if (calendarEvent.EventType == EventType.Meeting) { return string.Format("{0} from {1} to {2}", calendarEvent.DateStart.ToShortDateString(), calendarEvent.DateStart.ToShortTimeString(), calendarEvent.DateEnd.ToShortTimeString()); } return calendarEvent.DateStart.ToString(); }
public CalendarCellEventVm(CalendarEvent eventInstance) { Id = eventInstance.Id; Title = eventInstance.Title; DateStart = eventInstance.DateStart; DateEnd = eventInstance.DateEnd; Text = eventInstance.Text; IsAllDay = eventInstance.IsAllDay; Room = eventInstance.Room; EventType = eventInstance.EventType; }
public CalendarEventVm(CalendarEvent calendarEvent) { DateStart = calendarEvent.DateStart; DateEnd = calendarEvent.DateEnd; IsAllDay = calendarEvent.IsAllDay; EventType = calendarEvent.EventType; Id = calendarEvent.Id; Text = calendarEvent.Text; Title = calendarEvent.Title; Room = calendarEvent.Room; }
public void EmailEventReminder_Should_Notify_Users_On_One_Event() { //arrange var calendarEvent = new CalendarEvent {DateStart = DateTime.Now, EventType = EventType.Personal, Id = 1}; var testUsers = Builder<User>.CreateListOfSize(5).All().With(x => x.Live = LiveStatuses.Active).Build().ToList(); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory.Save(new EmailOnEventHistory {Event = calendarEvent, User = u})); //act _emailEventReminder.Start(); //assert _emailSenderMock.Verify(x => x.Send(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>()), Times.Exactly(1)); _emailedUserCount.ShouldBeEquivalentTo(testUsers.Count); }
public void EmailEventReminder_Should_Mark_Sent_Events_As_Notified() { //arrange var calendarEvent = new CalendarEvent { DateStart = DateTime.Now, EventType = EventType.Personal, Id = 1 }; var testUsers = Builder<User>.CreateListOfSize(5).All().With(x => x.Live = LiveStatuses.Active).Build().ToList(); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory .Save(new EmailOnEventHistory { Event = calendarEvent, User = u, EmailOnEventStatus = EmailOnEventStatus.NotSent })); //act _emailEventReminder.Start(); //assert _repoUnit.EmailOnEventHistory .Load(h => h.EmailOnEventStatus == EmailOnEventStatus.NotSent) .Should().BeEmpty(); }
private string getEmailSubject(CalendarEvent calendarEvent) { return string.Format("Calendar Event: {0}", calendarEvent.Title); }
private bool allDayEventRule(CalendarEvent calendarEvent) { return calendarEvent.DateStart.Date <= Config.Instance.Now + _timeBeforeAllDayReminder; }
private bool personalEventRule(CalendarEvent calendarEvent) { return calendarEvent.DateStart <= Config.Instance.Now + _timeBeforeReminder; }
private void saveToEmailHistory(CalendarEventVm calendarEventVm, CalendarEvent calendarEvent, int userId) { var eventUsers = getEventUsers(calendarEventVm); if (calendarEvent.EventType == EventType.Personal) eventUsers.Add(_unit.User.Get(userId)); eventUsers.ForEach(u => _unit.EmailOnEventHistory.Save(new EmailOnEventHistory {Event = calendarEvent, User = u})); }
public void EmailEventReminder_Should_Send_Proper_Meeting_Events() { //arrange var calendarEvent1 = new CalendarEvent { DateStart = DateTime.Now, EventType = EventType.Meeting, Id = 1 }; var calendarEvent2 = new CalendarEvent { DateStart = DateTime.Now - new TimeSpan(24, 0, 0), EventType = EventType.Meeting, Id = 2 }; var testUsers = Builder<User>.CreateListOfSize(5).All().With(x => x.Live = LiveStatuses.Active).Build().ToList(); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory.Save(new EmailOnEventHistory { Event = calendarEvent1, User = u })); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory.Save(new EmailOnEventHistory { Event = calendarEvent2, User = u })); //act _emailEventReminder.Start(); //assert _emailSenderMock.Verify(x => x.Send(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>()), Times.Exactly(2)); _emailedUserCount.ShouldBeEquivalentTo(testUsers.Count * 2); }
public void EmailEventReminder_Should_Not_Send_Improper_AllDay_Events() { //arrange var properCalendarEvent = new CalendarEvent { DateStart = DateTime.Now + new TimeSpan(24,0,0), EventType = EventType.Personal, Id = 1, IsAllDay = true }; var imProperCalendarEvent = new CalendarEvent { DateStart = DateTime.Now + new TimeSpan(48,0,0), EventType = EventType.Meeting, Id = 2, IsAllDay = true }; var testUsers = Builder<User>.CreateListOfSize(5).All().With(x => x.Live = LiveStatuses.Active).Build().ToList(); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory.Save(new EmailOnEventHistory { Event = properCalendarEvent, User = u })); testUsers.ForEach(u => _repoUnit.EmailOnEventHistory.Save(new EmailOnEventHistory { Event = imProperCalendarEvent, User = u })); //act _emailEventReminder.Start(); //assert _emailSenderMock.Verify(x => x.Send(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IEnumerable<string>>()), Times.Exactly(1)); _emailedUserCount.ShouldBeEquivalentTo(testUsers.Count); }