Join() public method

Adds a User to the Group.
public Join ( User newUser ) : void
newUser ActivEarth.Objects.Profile.User The User to be added to the Group.
return void
Beispiel #1
0
        public void TestUpdateGroup()
        {
            var owner = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };
            var member1 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };
            var member2 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };

            owner.UserID = UserDAO.CreateNewUser(owner, "password");
            member1.UserID = UserDAO.CreateNewUser(member1, "password");
            member2.UserID = UserDAO.CreateNewUser(member2, "password");

            List<string> tags = new List<string>();
            tags.Add("new");
            tags.Add("searchable");

            Group testGroup = new Group("Test1", owner, "This is a Group", tags);
            testGroup.Join(member1);
            Message message1 = new Message("HI GUYS", "THIS IS AN AWESOME GROUP", owner, "March 16 2012", "12:34:25 PM");
            testGroup.Post(message1);
            testGroup.ID = GroupDAO.CreateNewGroup(testGroup);

            testGroup.Name = "AWESOME GROUP! YAY!";
            testGroup.Quit(member1);
            testGroup.Join(member2);
            testGroup.HashTags.Add("hashtags");
            testGroup.HashTags.Remove("searchable");
            Message message2 = new Message("JUST KIDDING", "I HATE YOU GUYS", owner, "March 16 2012", "12:34:25 PM");
            testGroup.Post(message2);
            GroupDAO.UpdateGroup(testGroup);

            Group dbGroup = GroupDAO.GetGroupFromGroupId(testGroup.ID);
            Assert.AreEqual(dbGroup.Name, "AWESOME GROUP! YAY!");
            Assert.AreEqual(dbGroup.HashTags.ElementAt(1), "hashtags");
            Assert.AreEqual(dbGroup.Members.ElementAt(1).UserName, "member2");
            Assert.AreEqual(dbGroup.Wall.Messages.Last().Text, "I HATE YOU GUYS");
        }
Beispiel #2
0
        public void TestCreateGroup()
        {
            var owner = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };
            var member = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };
            var notMember = new User
            {
                UserName = "******",
                Age = 25, City = "Bleaksburg", Email = "*****@*****.**", FirstName = "I.C.", Gender = "M",
                Height = 60, LastName = "Poorcode", State = "VA", Weight = 130
            };

            owner.UserID = UserDAO.CreateNewUser(owner, "password");
            member.UserID = UserDAO.CreateNewUser(member, "password");
            notMember.UserID = UserDAO.CreateNewUser(notMember, "password");

            List<string> tags = new List<string>();
            tags.Add("new");
            tags.Add("searchable");
            tags.Add("hashtags");

            Group testGroup = new Group("Test", owner, "This is a Group", tags);
            testGroup.Join(member);

            int id = GroupDAO.CreateNewGroup(testGroup);
            Assert.AreNotEqual(id, 0);

            Group dbGroup = GroupDAO.GetGroupFromGroupId(id);
            Assert.AreEqual("Test", dbGroup.Name);
            Assert.AreEqual("owner", dbGroup.Owner.UserName);
            Assert.AreEqual("This is a Group", dbGroup.Description);

            for (int i = 0; i < tags.Count; i++)
            {
                Assert.AreEqual(tags.ElementAt(i), dbGroup.HashTags.ElementAt(i));
            }

            Assert.AreEqual(2, dbGroup.Members.Count);
            foreach (User u in dbGroup.Members) {
                Assert.IsNotNull(u);
                Assert.AreNotEqual("notMember", u.UserName);
            }
        }
Beispiel #3
0
        public void TestGetGroupByName()
        {
            var owner = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };
            var member1 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };
            var member2 = new User
            {
                UserName = "******",
                Age = 25,
                City = "Bleaksburg",
                Email = "*****@*****.**",
                FirstName = "I.C.",
                Gender = "M",
                Height = 60,
                LastName = "Poorcode",
                State = "VA",
                Weight = 130
            };

            owner.UserID = UserDAO.CreateNewUser(owner, "password");
            member1.UserID = UserDAO.CreateNewUser(member1, "password");
            member2.UserID = UserDAO.CreateNewUser(member2, "password");

            List<string> tags1 = new List<string>(); List<string> tags2 = new List<string>();
            tags1.Add("new"); tags2.Add("new");
            tags1.Add("searchable"); tags2.Add("searchable");
            tags2.Add("hashtags");

            Group testGroup1 = new Group("Test1", owner, "This is a Group", tags1);
            testGroup1.Join(member1);
            testGroup1.ID = GroupDAO.CreateNewGroup(testGroup1);

            Group testGroup2 = new Group("Test2", owner, "This is another Group", tags2);
            testGroup2.Join(member2);
            testGroup2.ID = GroupDAO.CreateNewGroup(testGroup2);

            Assert.AreNotEqual(testGroup1.ID, 0);
            Assert.AreNotEqual(testGroup2.ID, 0);

            List<Group> taggedGroups = GroupDAO.GetAllGroupsByName("Test2");
            Assert.AreEqual(taggedGroups.Count, 1);
            Assert.AreEqual(taggedGroups.First().Name, "Test2");
            Assert.AreEqual(2, taggedGroups.First().Members.Count);
            foreach (User u in taggedGroups.First().Members)
            {
                Assert.IsNotNull(u);
                Assert.AreNotEqual("member1", u.UserName);
            }

            taggedGroups = GroupDAO.GetAllGroupsByName("Test");
            Assert.AreEqual(taggedGroups.Count, 2);
            Assert.AreEqual(taggedGroups.First().Name, "Test1");
            Assert.AreEqual(taggedGroups.Last().Name, "Test2");
        }