public void CreateInvitation_ShouldCreate()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);
            Meeting meeting = TestDataHelper.GenerateMeeting();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);

            foreach (User user in meeting.InvitedPeople.Values)
            {
                userRep.CreateUser(user);
                inviteRep.Create(CreateInvitation(meeting, user));
            }

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);

            //assert
            TestDataHelper.PrintMeetingInfo(meeting);
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(TestDataHelper.CompareInvitedUsersLists
                (meeting.InvitedPeople.Values, resultMeeting.InvitedPeople.Values));
        }
Ejemplo n.º 2
0
        public void Delete_ShouldDelete()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);
            Meeting meeting = TestDataHelper.GenerateMeeting();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);
            foreach (User user in meeting.InvitedPeople.Values)
            {
                userRep.CreateUser(user);
                inviteRep.Create(CreateInvitation(meeting, user));
            }

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);
            if (resultMeeting != null) TestDataHelper.PrintMeetingInfo(resultMeeting);
            else Console.WriteLine("Meeting not exist");

            meetRep.DeleteMeeting(resultMeeting);
            resultMeeting = meetRep.GetMeeting(meeting.Id);

            //assert
            if (resultMeeting != null) TestDataHelper.PrintMeetingInfo(resultMeeting);
            else Console.WriteLine("Meeting deleted");
            Assert.IsNull(resultMeeting);
        }
        public void DeleteInvitation_ShouldDelete()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);

            Meeting meeting = TestDataHelper.GenerateMeeting();
            User invitedUser = TestDataHelper.GenerateUser();

            meeting.InvitedPeople.Clear();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);

            userRep.CreateUser(invitedUser);
            inviteRep.Create(CreateInvitation(meeting, invitedUser));

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);

            bool inviteResult = resultMeeting.InvitedPeople.Count == 1;
            TestDataHelper.PrintMeetingInfo(resultMeeting);

            inviteRep.Delete(CreateInvitation(resultMeeting, invitedUser));

            resultMeeting = meetRep.GetMeeting(meeting.Id);

            bool deleteResult = resultMeeting.InvitedPeople.Count == 0;

            //assert
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(inviteResult & deleteResult);
        }
        public void IsExistInvitation_ShouldExist()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);

            Meeting meeting = TestDataHelper.GenerateMeeting();
            User invitedUser = TestDataHelper.GenerateUser();

            meeting.InvitedPeople.Clear();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);
            userRep.CreateUser(invitedUser);

            inviteRep.Create(CreateInvitation(meeting, invitedUser));

            //assert
            Assert.IsTrue(inviteRep.IsExist(CreateInvitation(meeting, invitedUser)));
        }
        public void IsExistInvitation_ShouldNotExist()
        {
            //arange
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);

            Meeting meeting = TestDataHelper.GenerateMeeting();
            User invitedUser = TestDataHelper.GenerateUser();

            //act

            //assert
            Assert.IsFalse(inviteRep.IsExist(CreateInvitation(meeting, invitedUser)));
        }