AddSubGroup() public method

Přidání nové podgrupy k dané nadgrupě
public AddSubGroup ( User user, Group group, Group child ) : void
user User Zakladatel skupiny
group Group ID groupy do které budu přidávat podgrupu
child Group nová podgrupa
return void
Beispiel #1
0
        public void AddSubGroupTest()
        {
            FelBookDBEntities DBEntities = new FelBookDBEntities();
            IWallService wallService = null;
            GroupService target = new GroupService(DBEntities, wallService);

            User user = User.CreateUser(0, "group", "creator", DateTime.Now,
                "mail", "groupCreator", "1234");
            DBEntities.UserSet.AddObject(user);

            Group parentGroup = Group.CreateGroup(0, "parentGroup", "parentGroupDescription");
            user.CreatedGroups.Add(parentGroup);
            user.AdminedGroups.Add(parentGroup);
            user.JoinedGroups.Add(parentGroup);
            DBEntities.GroupSet.AddObject(parentGroup);
            DBEntities.SaveChanges();

            Group childGroup = Group.CreateGroup(1, "childGroup", "childGroupDescription");
            target.AddSubGroup(user, parentGroup, childGroup);

            Assert.AreEqual(user, childGroup.Creator);
            Assert.IsTrue(childGroup.Administrators.Contains(user));
            Assert.IsTrue(childGroup.Users.Contains(user));

            Assert.IsTrue(user.AdminedGroups.Contains(childGroup));
            Assert.IsTrue(user.CreatedGroups.Contains(childGroup));
            Assert.IsTrue(user.JoinedGroups.Contains(childGroup));

            Assert.AreEqual(parentGroup, childGroup.Parent);
            Assert.IsTrue(parentGroup.Children.Contains(childGroup));

            DBEntities.GroupSet.DeleteObject(childGroup);
            DBEntities.GroupSet.DeleteObject(parentGroup);
            DBEntities.UserSet.DeleteObject(user);
            DBEntities.SaveChanges();
        }