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.");
        }
        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));
        }
        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");
        }