public void ToStringTest() { //test wish for user tostring Wish wish = GetSimpleWish(); wish.WishUser = UserTests.GetSimpleUser(1); Assert.AreEqual("Ønsker at snakke med Bob Bobsen.", wish.ToString(), "ToString not correct for user wish"); //test organization wish.WishUser = null; wish.WishOrganization = new Organization("Org") { Id = 1 }; Assert.AreEqual("Ønsker at snakke med en person som har arbejdet i organisationen \"Org\".", wish.ToString(), "ToString not correct for organization."); wish.WishOrganizationTime = 1; Assert.AreEqual("Ønsker at snakke med en person som har arbejdet i organisationen \"Org\" i 1 år.", wish.ToString(), "ToString not correct for organization (years)."); wish.WishOrganization = null; Assert.AreEqual("Ønsker at snakke med en person som har arbejdet i en organisation i 1 år.", wish.ToString(), "ToString not correct for organization time."); //Test interests wish = GetSimpleWish(); wish.WishInterests = new List <WishInterests>() { new WishInterests(InterestTests.GetSimpleInterest(), wish) }; Assert.AreEqual("Ønsker at snakke med en person som har 1 interesse.", wish.ToString(), "ToString not correct for single interest"); wish.WishInterests.Add(new WishInterests(InterestTests.GetSimpleInterest(), wish)); Assert.AreEqual("Ønsker at snakke med en person som har 2 interesser.", wish.ToString(), "ToString not correct for multiple interests"); //Test businesses wish = GetSimpleWish(); wish.WishBusinesses = new List <WishBusinesses>() { new WishBusinesses(BusinessTests.GetSimpleBusiness(), wish) }; Assert.AreEqual("Ønsker at snakke med en person som arbejder i 1 erhverv.", wish.ToString(), "ToString not correct for single business"); //Test wish with 2 parts wish.WishInterests = new List <WishInterests>() { new WishInterests(InterestTests.GetSimpleInterest(), wish) }; Assert.AreEqual("Ønsker at snakke med en person som har 1 interesse og arbejder i 1 erhverv.", wish.ToString(), "ToString not correct with 2 wish parts"); //Test wish with 3 parts wish.WishOrganization = new Organization("Org") { Id = 1 }; Assert.AreEqual("Ønsker at snakke med en person som har 1 interesse, arbejder i 1 erhverv og har arbejdet i organisationen \"Org\".", wish.ToString(), "ToString not correct with 3 wish parts"); }
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 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"); }