public void Notification_On_Event_Cancelled() { //Arrange var theHost = new Person { PersonId = 3, FirstName = "Matt", LastName = "Harmin" }; var peopleList = new List<Person> { new Person {PersonId = 1, FirstName = "Joe", LastName = "Smith" }, new Person {PersonId = 2, FirstName = "Sally", LastName = "Hardy" }, }; var theEvent = new Event { EventId = 1, Title = "My Test Event", StartDate = DateTime.Now, Coordinator = theHost, RegisteredInvites = peopleList }; A.CallTo(() => EventRepo.GetAll()).Returns(new List<Event> { theEvent }.AsQueryable()); A.CallTo(() => PersonRepo.GetAll()).Returns(peopleList.AsQueryable()); A.CallTo(() => InvitationRepo.GetAll()).Returns(new List<PendingInvitation>().AsQueryable()); //Act var notification = NotifyService.GetNotificationForEventCancelled(theEvent.EventId, 1, 0); //Assert string hostName = string.Format("{0} {1}", theHost.FirstName, theHost.LastName); string expectedMessage = string.Format(Constants.MESSAGE_CANCELLED_TEMPLATE, theEvent.Title, hostName); Assert.AreEqual(notification.Title, Constants.MESSAGE_CANCELLED_TITLE); Assert.AreEqual(notification.Message, expectedMessage); }
public void Notification_On_Attendee_Removed() { //Arrange var theHost = new Person { PersonId = 3, FirstName = "Matt", LastName = "Harmin" }; var thePerson = new Person{PersonId = 1, FirstName = "Joe", LastName = "Smith", NotifyWithFacebook = true, NotifyWithEmail = false}; var theEvent = new Event { EventId = 1, Title = "My Test Event", StartDate = DateTime.Now, Coordinator = theHost }; var personList = new List<Person>{thePerson}; var eventList = new List<Event>{theEvent}; A.CallTo(() => PersonRepo.GetAll()).Returns(personList.AsQueryable()); A.CallTo(() => EventRepo.GetAll()).Returns(eventList.AsQueryable()); A.CallTo(() => InvitationRepo.GetAll()).Returns(new List<PendingInvitation>().AsQueryable()); //Act var notification = NotifyService.GetPersonRemovedFromEventNotification(theEvent.EventId, thePerson.PersonId, 0); //Assert string hostName = string.Format("{0} {1}", theHost.FirstName, theHost.LastName); string expectedMessage = string.Format(Constants.MESSAGE_REMOVE_TEMPLATE, hostName, theEvent.Title, theEvent.StartDate.ToShortDateString(), theEvent.StartDate.ToShortTimeString()); Assert.AreEqual(notification.SendToEmail, personList[0].NotifyWithEmail); Assert.AreEqual(notification.SendToFacebook, personList[0].NotifyWithFacebook); Assert.AreEqual(notification.Title, Constants.MESSAGE_REMOVE_TITLE); Assert.AreEqual(notification.Message, expectedMessage); }
private string GetPersonName(Person thePerson) { var personName = (string.IsNullOrEmpty(thePerson.FirstName) || string.IsNullOrEmpty(thePerson.LastName)) ? thePerson.UserName : string.Format("{0} {1}", thePerson.FirstName, thePerson.LastName); return personName; }