/// <summary> /// Get an event view model for testing purposes /// </summary> /// <param name="id">The id of the view model (default = 0)</param> protected EditEventViewModel GetTestEventViewModel(int id = 0) { //People var theHost = new PersonViewModel { PersonId = 1 }; var guestOne = new PersonViewModel{ PersonId = 2 }; var guestTwo = new PersonViewModel { PersonId = 3 }; var theInvitees = new List<PersonViewModel> { guestOne, guestTwo }; //Food var burgers = new FoodItemViewModel { FoodItemId = 1, Title = "Hambergers", Description = "Apple bacon smoked burgers for 10 people." }; var coke = new FoodItemViewModel { FoodItemId = 2, Title = "Coke", Description = "Two 6 packs" }; var cheese = new FoodItemViewModel { FoodItemId = 3, Title = "Cheese", Description = "Good with crackers" }; var foodForTheParty = new List<FoodItemViewModel> { coke, cheese }; //Games var settlers = new GameViewModel { GameId = 1, Title = "Settlers of Catan", Description = "The best game ever for up to four people" }; var blockus = new GameViewModel { GameId = 2, Title = "Blockus", Description = "Fun game of shape fitting for up four people." }; var gamesForTheParty = new List<GameViewModel> { settlers,blockus }; var viewModel = new EditEventViewModel { EventId = id, Title = "My Test Event", Description = "This is a fun test event", Location = "My House", StartDate = DateTime.Now, StartTime = "5:00 PM", EndTime = "2:00 AM", WillBringTheseFoodItems = foodForTheParty, WillBringTheseGames = gamesForTheParty, PeopleInvited = theInvitees }; return viewModel; }
protected PersonViewModel GetTestInviteeViewModel(int id = 0) { var iAmInvited = new PersonViewModel { PersonId = id, FirstName = "Sam", LastName = "Mercuiou", }; //Build a list of food items... iAmInvited.MyFoodItems.Add(GetTestFoodItemViewModel(4)); iAmInvited.MyFoodItems.Add(GetTestFoodItemViewModel(5)); //Build list of games... iAmInvited.MyGames.Add(GetTestGameViewModel(4)); iAmInvited.MyGames.Add(GetTestGameViewModel(5)); return iAmInvited; }
protected PersonViewModel GetTestFriend(int id = 0) { var friend = new PersonViewModel { PersonId = id, FirstName = "Best", LastName = "Friend" }; return friend; }
/// <summary> /// Get a list of all registered and non registered guests that have NOT been invited to the specified event /// </summary> /// <param name="eventGuestIds"></param> /// <param name="personFriendIds"></param> /// <param name="eventId"></param> /// <returns></returns> private List<PersonViewModel> GetNonSelectedGuests(List<int> eventGuestIds, List<int> personFriendIds, int eventId) { var guestList = new List<PersonViewModel>(); var unSelectedGuestIds = personFriendIds.Where(x => !eventGuestIds.Contains(x)); _personRepository.GetAll() .Where(x => unSelectedGuestIds.Contains(x.PersonId)) .OrderBy(x => x.FirstName) .ToList().ForEach(x => { var viewModel = new PersonViewModel(x); viewModel.IsRegistered = true; guestList.Add(viewModel); }); //Make the unregistered numbers posative var unRegisteredIds = new List<int>(); unSelectedGuestIds.Where(x => x < 0) .ToList() .ForEach(x => unRegisteredIds.Add(Math.Abs(x))); _inviteRepository.GetAll() .Where(x => unRegisteredIds.Contains(x.PendingInvitationId)) .OrderBy(x => x.FirstName) .ToList().ForEach(x => { var viewModel = new PersonViewModel { PersonId = -x.PendingInvitationId, FirstName = x.FirstName, LastName = x.LastName, Email = x.Email, IsRegistered = false }; guestList.Add(viewModel); }); return guestList; }
public void Uninvite_People() { //Arrange var personOne = new Person { PersonId = 1, MyFoodItems = new List<FoodItem>(), MyGames = new List<Game>()}; var personTwo = new Person { PersonId = 2, MyFoodItems = new List<FoodItem>(), MyGames = new List<Game>() }; var personThree = new Person { PersonId = 3, MyFoodItems = new List<FoodItem>(), MyGames = new List<Game>() }; var vmPersonOne = new PersonViewModel(personOne); var vmPersonTwo = new PersonViewModel(personTwo); var vmEmailPerson = new PersonViewModel { PersonId = -3, Email = "*****@*****.**" }; var viewModel = new EditEventViewModel { PeopleInvited = new List<PersonViewModel> { vmPersonOne, vmPersonTwo, vmEmailPerson } }; var dataModel = new Event { RegisteredInvites = new List<Person> { new Person { PersonId = 2 }, new Person { PersonId = 3 } }, UnRegisteredInvites = new List<PendingInvitation> { new PendingInvitation { PendingInvitationId = 3, Email = "*****@*****.**" } }, PeopleWhoAccepted = new List<Person> { new Person { PersonId = 2 } }, PeopleWhoDeclined = new List<Person> { new Person { PersonId = 3 } } }; A.CallTo(() => PersonRepo.GetAll()).Returns(new EnumerableQuery<Person>(new[] {personOne, personTwo, personThree})); //Act viewModel.PeopleInvited.Remove(vmPersonOne); viewModel.PeopleInvited.Remove(vmPersonTwo); viewModel.PeopleInvited.Remove(vmEmailPerson); EventService.UninvitePeople(dataModel, viewModel); //Assert Assert.AreEqual(dataModel.RegisteredInvites.Count, 0); Assert.AreEqual(dataModel.UnRegisteredInvites.Count, 0); Assert.AreEqual(dataModel.PeopleWhoAccepted.Count, 0); Assert.AreEqual(dataModel.PeopleWhoDeclined.Count, 0); }
public void Invite_New_People_By_Email() { //Arrange var ben = new PersonViewModel{ PersonId = -1, Email = "*****@*****.**", FirstName = "Ben", LastName = "Bufford" }; var dan = new PersonViewModel { PersonId = -2, Email = "*****@*****.**", FirstName = "Dan", LastName = "Gidman" }; var herb = new PersonViewModel { PersonId = -3, Email = "*****@*****.**", FirstName = "Herb", LastName = "Neese" }; var viewModel = new EditEventViewModel { PeopleInvited = new List<PersonViewModel> { dan, herb } }; var dataModel = new Event { Coordinator = new Person { PersonId = 1, MyUnRegisteredFriends = new List<PendingInvitation>()}, UnRegisteredInvites = new List<PendingInvitation> { new PendingInvitation { PendingInvitationId = 2, Email = "*****@*****.**" }, new PendingInvitation { PendingInvitationId = 3, Email = "*****@*****.**" } }, RegisteredInvites = new List<Person>() }; A.CallTo(() => InvitationRepo.GetAll()).Returns(new List<PendingInvitation> { new PendingInvitation { PendingInvitationId = 1, Email = "*****@*****.**" } }.AsQueryable()); //Act viewModel.PeopleInvited.Add(ben); EventService.InviteNewPeople(dataModel, viewModel); //Assert Assert.AreEqual(dataModel.UnRegisteredInvites.Count, 3); }
public void Invite_New_People() { //Arrange var personOne = new PersonViewModel{PersonId = 1}; var personTwo = new PersonViewModel { PersonId = 2 }; var personThree = new PersonViewModel { PersonId = 3 }; var theHost = new Person { PersonId = 4, MyRegisteredFriends = new List<Person>(), MyUnRegisteredFriends = new List<PendingInvitation>()}; var viewModel = new EditEventViewModel{ PeopleInvited = new List<PersonViewModel>{personTwo, personThree} }; var dataModel = new Event { Coordinator = theHost, RegisteredInvites = new List<Person> {new Person{PersonId = 2}, new Person{PersonId = 3}}, UnRegisteredInvites = new List<PendingInvitation>() }; A.CallTo(() => PersonRepo.GetAll()).Returns(new List<Person> { new Person() { PersonId = 1 } }.AsQueryable()); //Act viewModel.PeopleInvited.Add(personOne); EventService.InviteNewPeople(dataModel, viewModel); //Assert Assert.AreEqual(dataModel.RegisteredInvites.Count, 3); }