Add() public method

Přidání nové skupiny
public Add ( User user, Group group ) : void
user User uživatel, který vytváří skupinu
group Group skupina
return void
Beispiel #1
0
        public void AddTest()
        {
            FelBookDBEntities DBEntities = new FelBookDBEntities();
            IWallService wallService = null; // Snad ji zatím nepotřebuji
            GroupService target = new GroupService(DBEntities, wallService);

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

            Group group = Group.CreateGroup(0, "newGroup", "groupDescription");
            target.Add(user, group);

            Assert.IsTrue(DBEntities.GroupSet.ToList().Contains(group));
            Assert.AreEqual(user, group.Creator);
            Assert.IsTrue(group.Administrators.Contains(user));
            Assert.IsTrue(group.Users.Contains(user));

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

            DBEntities.GroupSet.DeleteObject(group);
            DBEntities.UserSet.DeleteObject(user);
            DBEntities.SaveChanges();
        }