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 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));
        }
Exemplo n.º 3
0
        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");
        }
Exemplo n.º 4
0
        public void GetUsersTest()
        {
            Event testEvent = GetSimpleEvent();

            testEvent.Invites = new List <Invite>()
            {
                new Invite(testEvent, UserTests.GetSimpleUser(), DateTime.Now),
                new Invite(testEvent, UserTests.GetSimpleUser(), DateTime.Now)
            };

            List <User> eventUsers = testEvent.GetUsers().ToList();

            Assert.AreEqual(2, eventUsers.Count, "The list doesnt contain all the users in the event");
            Assert.AreEqual("Bob", eventUsers[1].FirstName, "The users arent correct");
        }
        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");
        }
Exemplo n.º 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");
        }
Exemplo n.º 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));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a simple <see cref="Event"/> object
 /// </summary>
 /// <param name="eventId">The id the event should have</param>
 /// <param name="ownerId">The id the event owner should have</param>
 /// <returns>A simple <see cref="Event"/></returns>
 public static Event GetSimpleEvent(int eventId = 0, int ownerId = 0)
 {
     return(new Event("My 1st Event", "My 783945uisdfsf{[]{£@$@$ event description", UserTests.GetSimpleUser(ownerId), AddressTests.GetSimpleAddress(), eventId));
 }
Exemplo n.º 11
0
        public void ToStringTest()
        {
            UsersOrganizations usersOrganizations = new UsersOrganizations(OrganizationTests.GetSimpleOrganization(), UserTests.GetSimpleUser(), new DateTime(2000, 10, 10));

            Assert.AreEqual("My Organization: Ansættelsesdato 10-10-2000", usersOrganizations.ToString(), "ToString returned wrong string");
            usersOrganizations.EndDate = new DateTime(2001, 10, 10);
            Assert.AreEqual("My Organization: 10-10-2000 - 10-10-2001", usersOrganizations.ToString(), "ToString with 2 datetimes returned wrong string");
        }
Exemplo n.º 12
0
        public void UsersOrganizationsTest()
        {
            //Test hiring date
            UsersOrganizations usersOrganizations = new UsersOrganizations(OrganizationTests.GetSimpleOrganization(), UserTests.GetSimpleUser(), new DateTime(2000, 10, 10));

            Assert.ThrowsException <ArgumentException>(() => { usersOrganizations.EndDate = new DateTime(1999, 10, 10); }, "EndDate cannot be less than StartDate");
            usersOrganizations.EndDate = new DateTime(2001, 10, 10);
            Assert.ThrowsException <ArgumentException>(() => { usersOrganizations.StartDate = new DateTime(2002, 10, 10); }, "StartDate cannot be higher than EndDate");
        }
Exemplo n.º 13
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));
 }