public void GetPossibleMeetingsTest()
        {
            //Test parameter null
            Assert.ThrowsException <ArgumentNullException>(() => { MeetingScore.GetPossibleMeetings(null, 0); });
            Event @event = EventTests.GetSimpleEvent(1);

            //Test creation
            List <User> users = new List <User>()
            {
                UserTests.GetSimpleUser(1),
                UserTests.GetSimpleUser(2),
                UserTests.GetSimpleUser(3),
                UserTests.GetSimpleUser(4)
            };

            for (int i = 0; i < 4; i++)
            {
                users[i].Invites.Add(new Invite(@event, users[i], DateTime.Now));
            }
            List <MeetingScore> meetings = MeetingScore.GetPossibleMeetings(users, @event.Id);

            //3+2+1 = 6
            Assert.AreEqual(6, meetings.Count, "The correct amount of meetings wasnt created");
            Assert.AreEqual(3, meetings.Count(m => m.Person1.Id == 3 || m.Person2.Id == 3), "the users arent in the correct amount of meetings");
        }
        public void SeanceTest()
        {
            Seance seance = new Seance(EventTests.GetSimpleEvent(), 1, new DateTime(2000, 10, 10), new DateTime(2000, 10, 11));

            Assert.ThrowsException <ArgumentNullException>(() => { seance.Meetings = null; }, "Meetings cannot be null");
            Assert.ThrowsException <ArgumentNullException>(() => { seance.UserPauses = null; }, "UserPauses cannot be null");
        }
        public void MeetingContainsUserTest()
        {
            User userOne   = UserTests.GetSimpleUser(1);
            User userTwo   = UserTests.GetSimpleUser(2);
            User userThree = UserTests.GetSimpleUser(3);

            Meeting meeting = new Meeting(userOne, userTwo, new Seance(EventTests.GetSimpleEvent(), 1, new DateTime(2000, 10, 10), new DateTime(2000, 10, 11)));

            Assert.IsTrue(meeting.MeetingContainsUser(userOne.Id));
            Assert.IsTrue(meeting.MeetingContainsUser(userTwo.Id));
            Assert.IsFalse(meeting.MeetingContainsUser(userThree.Id));
        }
        public void MeetingScoreTest()
        {
            //Create users
            Event @event = EventTests.GetSimpleEvent(1);
            User  user1  = UserTests.GetSimpleUser(0);
            User  user2  = UserTests.GetSimpleUser(1);

            //Test invite errors
            Assert.ThrowsException <ArgumentException>(() => { new MeetingScore(0, user1, user2); });

            //test users
            user1.Invites.Add(new Invite(@event, user1, DateTime.Now));
            user2.Invites.Add(new Invite(@event, user2, DateTime.Now));

            Assert.ThrowsException <ArgumentNullException>(() => { new MeetingScore(1, null, user2); });
            Assert.ThrowsException <ArgumentNullException>(() => { new MeetingScore(1, user1, null); });

            //test score
            user1.Wishes = new List <Wish>()
            {
                new Wish(UserTests.GetSimpleUser(1), @event, 10)
                {
                    WishUser = user2
                }
            };
            user2.Wishes = new List <Wish>()
            {
                new Wish(UserTests.GetSimpleUser(1), EventTests.GetSimpleEvent(10), 10)
                {
                    WishUser = UserTests.GetSimpleUser(0)
                },                                                                                                                  //ignored wish (wrong event id)
                new Wish(UserTests.GetSimpleUser(1), @event, 10)
                {
                    WishInterests = new List <WishInterests>()
                    {
                        new WishInterests(new Interest("a")
                        {
                            Id = 1
                        }, WishTests.GetSimpleWish())
                    }
                }
            };
            MeetingScore meetingScore = new MeetingScore(1, user1, user2);

            Assert.AreEqual(1000, meetingScore.Score, "Wrong score calculated");
        }
        public void CalculateHappinessScoreTest()
        {
            //Create test user
            User user = GetSimpleUser(1);

            user.UsersInterests = new List <UsersInterest>()
            {
                new UsersInterest(InterestTests.GetSimpleInterest(0), user),
                new UsersInterest(InterestTests.GetSimpleInterest(1), user),
                new UsersInterest(InterestTests.GetSimpleInterest(2), user),
                new UsersInterest(InterestTests.GetSimpleInterest(3), user),
                new UsersInterest(InterestTests.GetSimpleInterest(4), user),
                new UsersInterest(InterestTests.GetSimpleInterest(5), user)
            };
            user.UsersBusinesses = new List <UsersBusiness>()
            {
                new UsersBusiness(BusinessTests.GetSimpleBusiness(0), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(1), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(2), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(3), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(4), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(5), user)
            };

            //Create wish list
            List <Wish> wishList = new List <Wish>()
            {
                new Wish(GetSimpleUser(), EventTests.GetSimpleEvent(), 10)
                {
                    WishUser = GetSimpleUser(1)
                }
            };

            wishList.Add(WishTests.GetSimpleWish());
            wishList[1].WishInterests = new List <WishInterests>()
            {
                new WishInterests(InterestTests.GetSimpleInterest(0), wishList[1]),
                new WishInterests(InterestTests.GetSimpleInterest(1), wishList[1]),
                new WishInterests(InterestTests.GetSimpleInterest(2), wishList[1]),
                new WishInterests(InterestTests.GetSimpleInterest(3), wishList[1]),
                new WishInterests(InterestTests.GetSimpleInterest(4), wishList[1]),
                new WishInterests(InterestTests.GetSimpleInterest(5), wishList[1])
            };
            Assert.AreEqual(1000, user.CalculateHappinessScore(wishList), "Happiness score was supposed to be the highest score of all the wishes.");
        }
Beispiel #6
0
        public void WishTest()
        {
            Wish testWish = GetSimpleWish();

            //test wishUser
            new Wish(UserTests.GetSimpleUser(0), EventTests.GetSimpleEvent(0), 10)
            {
                WishUser = null
            };

            //Test wishorganization
            new Wish(UserTests.GetSimpleUser(0), EventTests.GetSimpleEvent(0), 10)
            {
                WishOrganization = null
            };
            new Wish(UserTests.GetSimpleUser(0), EventTests.GetSimpleEvent(0), 10)
            {
                WishOrganizationTime = null
            };

            //Test lists
            Assert.ThrowsException <ArgumentNullException>(() => { testWish.WishBusinesses = null; }, "WishBusinesses cannot be empty");
            Assert.ThrowsException <ArgumentNullException>(() => { testWish.WishInterests = null; }, "WishInterests cannot be empty");
        }
Beispiel #7
0
 /// <summary>
 /// Creates a simple <see cref="Wish"/> object
 /// </summary>
 /// <param name="userId">the id of the user who is wishing</param>
 /// <param name="eventId">the id of the event the wish is for</param>
 /// <returns>A simple <see cref="Wish"/></returns>
 public static Wish GetSimpleWish(int userId = 0, int eventId = 0)
 {
     return(new Wish(UserTests.GetSimpleUser(userId), EventTests.GetSimpleEvent(eventId), 10));
 }
 public void UserPauseTest()
 {
     new UserPause(UserTests.GetSimpleUser(), new Seance(EventTests.GetSimpleEvent(), 0, new DateTime(2000, 10, 10), new DateTime(2000, 10, 11)));
 }
        public void SortTest()
        {
            //Create test users
            Event @event    = EventTests.GetSimpleEvent(0);
            User  testUser1 = UserTests.GetSimpleUser(1);
            User  testUser2 = UserTests.GetSimpleUser(2);
            User  testUser3 = UserTests.GetSimpleUser(3);
            User  testUser4 = UserTests.GetSimpleUser(4);

            testUser1.Wishes = new List <Wish>()
            {
                new Wish(testUser1, @event, 10)
                {
                    WishUser = testUser2
                },
                new Wish(testUser1, @event, 10)
                {
                    WishUser = testUser4
                }
            };
            testUser1.UsersInterests = new List <UsersInterest>()
            {
                new UsersInterest(InterestTests.GetSimpleInterest(0), testUser1)
            };
            testUser2.Wishes = new List <Wish>()
            {
                new Wish(testUser2, @event, 10)
                {
                    WishUser = testUser1
                }
            };
            testUser3.Wishes = new List <Wish>()
            {
                new Wish(testUser3, @event, 10)
                {
                    WishInterests = new List <WishInterests>()
                    {
                        new WishInterests(InterestTests.GetSimpleInterest(), WishTests.GetSimpleWish())
                    }
                }
            };
            testUser4.Wishes = new List <Wish>()
            {
                new Wish(testUser4, @event, 10)
                {
                    WishUser = testUser1
                }
            };
            testUser1.Invites.Add(new Invite(@event, testUser1, new DateTime(2000, 10, 9)));
            testUser2.Invites.Add(new Invite(@event, testUser2, new DateTime(2000, 10, 9)));
            testUser3.Invites.Add(new Invite(@event, testUser3, new DateTime(2000, 10, 10)));
            testUser4.Invites.Add(new Invite(@event, testUser4, new DateTime(2000, 10, 12)));

            //test meetings
            Assert.ThrowsException <ArgumentNullException>(() => { MeetingScore.Sort(null, new MeetingScore(0, testUser1, testUser2)); });
            Assert.ThrowsException <ArgumentNullException>(() => { MeetingScore.Sort(new MeetingScore(0, testUser1, testUser2), null); });

            //Create test meeting scores
            MeetingScore testMeeting1 = new MeetingScore(@event.Id, testUser1, testUser2);
            MeetingScore testMeeting2 = new MeetingScore(@event.Id, testUser2, testUser1);
            MeetingScore testMeeting3 = new MeetingScore(@event.Id, testUser3, testUser1);
            MeetingScore testMeeting4 = new MeetingScore(@event.Id, testUser4, testUser1);

            //do tests
            Assert.AreEqual(0, MeetingScore.Sort(testMeeting1, testMeeting2));
            Assert.AreEqual(-1, MeetingScore.Sort(testMeeting1, testMeeting3));
            Assert.AreEqual(1, MeetingScore.Sort(testMeeting3, testMeeting1));
            Assert.AreEqual(-1, MeetingScore.Sort(testMeeting1, testMeeting4));
            Assert.AreEqual(1, MeetingScore.Sort(testMeeting4, testMeeting1));
        }
Beispiel #10
0
 /// <summary>
 /// Creates an simple <see cref="Invite"/> object
 /// </summary>
 /// <param name="eventId">the id of the event the invite is for</param>
 /// <param name="userId">the id of the user the invite is to</param>
 /// <returns>An simple <see cref="Invite"/></returns>
 public static Invite GetSimpleInvite(int eventId = 0, int userId = 0)
 {
     return(new Invite(EventTests.GetSimpleEvent(eventId), UserTests.GetSimpleUser(userId), DateTime.Now));
 }
        public void CalculateHappinessScoreTest1()
        {
            //Create test user
            User user = GetSimpleUser(1);

            user.UsersInterests = new List <UsersInterest>()
            {
                new UsersInterest(InterestTests.GetSimpleInterest(0), user),
                new UsersInterest(InterestTests.GetSimpleInterest(1), user),
                new UsersInterest(InterestTests.GetSimpleInterest(2), user),
                new UsersInterest(InterestTests.GetSimpleInterest(3), user),
                new UsersInterest(InterestTests.GetSimpleInterest(4), user),
                new UsersInterest(InterestTests.GetSimpleInterest(5), user)
            };
            user.UsersBusinesses = new List <UsersBusiness>()
            {
                new UsersBusiness(BusinessTests.GetSimpleBusiness(0), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(1), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(2), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(3), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(4), user),
                new UsersBusiness(BusinessTests.GetSimpleBusiness(5), user)
            };

            //Test if 100% interest wish gives correct score
            Wish wish = WishTests.GetSimpleWish();

            wish.WishInterests = new List <WishInterests>()
            {
                new WishInterests(InterestTests.GetSimpleInterest(0), wish),
                new WishInterests(InterestTests.GetSimpleInterest(1), wish),
                new WishInterests(InterestTests.GetSimpleInterest(2), wish),
                new WishInterests(InterestTests.GetSimpleInterest(3), wish),
                new WishInterests(InterestTests.GetSimpleInterest(4), wish),
                new WishInterests(InterestTests.GetSimpleInterest(5), wish)
            };
            Assert.AreEqual(700, user.CalculateHappinessScore(wish), "Happiness score got the wrong result");

            //Test if 50% interest/business gives correct score
            wish = new Wish(GetSimpleUser(), EventTests.GetSimpleEvent(), 10)
            {
                WishInterests = new List <WishInterests>()
                {
                    new WishInterests(InterestTests.GetSimpleInterest(0), wish),
                    new WishInterests(InterestTests.GetSimpleInterest(1), wish),
                    new WishInterests(InterestTests.GetSimpleInterest(2), wish)
                },
                WishBusinesses = new List <WishBusinesses>()
                {
                    new WishBusinesses(BusinessTests.GetSimpleBusiness(0), wish),
                    new WishBusinesses(BusinessTests.GetSimpleBusiness(1), wish),
                    new WishBusinesses(BusinessTests.GetSimpleBusiness(2), wish),
                    new WishBusinesses(BusinessTests.GetSimpleBusiness(101), wish)
                }
            };
            //business score = 600/725
            //interest score = 725/725
            Assert.AreEqual(639, user.CalculateHappinessScore(wish), "Happiness score was not supposed to be 700");

            //Test if user wishes outputs correct score
            wish = new Wish(GetSimpleUser(), EventTests.GetSimpleEvent(), 10)
            {
                WishUser = GetSimpleUser(1)
            };
            Assert.AreEqual(1000, user.CalculateHappinessScore(wish), "Happiness score was not supposed to be 1000 because it was a user wish");
        }