예제 #1
0
        public void Delete_DeletesEventInviteeFromDatabase()
        {
            //Arrange
            string   eventName     = "July 4th BBQ";
            DateTime eventDate     = new DateTime(2019, 07, 04);
            string   eventLocation = "Capitol Hill";
            int      menusId       = 1;
            Event    newEvent      = new Event(eventName, eventDate, eventLocation, menusId);

            newEvent.Save();

            string  inviteeName         = "Jane Doe";
            string  inviteeEmailAddress = "*****@*****.**";
            Invitee newInvitee          = new Invitee(inviteeName, inviteeEmailAddress);

            newInvitee.Save();

            //Act
            Event   foundEvent   = Event.Find(newEvent.GetId());
            Invitee foundInvitee = Invitee.Find(newInvitee.GetId());

            foundInvitee.AddEvent(foundEvent);

            List <Event> result = foundInvitee.GetEvents();

            foundInvitee.DeleteEvent(foundEvent);
            List <Event> testList = foundInvitee.GetEvents();

            //Assert
            CollectionAssert.AreNotEqual(testList, result);
        }
        public ActionResult Edit(int inviteeId)
        {
            Invitee      invitee = Invitee.Find(inviteeId);
            List <Event> events  = invitee.GetEvents();
            Dictionary <string, object> model = new Dictionary <string, object>();

            model.Add("invitee", invitee);
            model.Add("events", events);
            return(View(model));
        }
예제 #3
0
        public void GetEvents_RetrievesAllEventsWithInvitee_EventList()
        {
            //Arrange
            string   eventName1     = "July 4th BBQ";
            DateTime eventDate1     = new DateTime(2019, 07, 04);
            string   eventLocation1 = "Capitol Hill";
            int      menusId1       = 1;
            Event    newEvent1      = new Event(eventName1, eventDate1, eventLocation1, menusId1);

            newEvent1.Save();

            string   eventName2     = "Birthday Party";
            DateTime eventDate2     = new DateTime(2019, 05, 03);
            string   eventLocation2 = "Saltys";
            int      menusId2       = 2;
            Event    newEvent2      = new Event(eventName2, eventDate2, eventLocation2, menusId2);

            newEvent2.Save();

            string  inviteeName         = "Jane Doe";
            string  inviteeEmailAddress = "*****@*****.**";
            Invitee newInvitee          = new Invitee(inviteeName, inviteeEmailAddress);

            newInvitee.Save();

            //Act
            Event   foundEvent1  = Event.Find(newEvent1.GetId());
            Event   foundEvent2  = Event.Find(newEvent2.GetId());
            Invitee foundInvitee = Invitee.Find(newInvitee.GetId());

            foundInvitee.AddEvent(foundEvent1);
            foundInvitee.AddEvent(foundEvent2);

            List <Event> newList = new List <Event> {
                newEvent1, newEvent2
            };
            List <Event> resultList = foundInvitee.GetEvents();

            //Assert
            CollectionAssert.AreEqual(newList, resultList);
        }