Exemplo n.º 1
0
        public void Can_Assign_And_Get_Children()
        {
            var groupA = new Group()
            {
                Name = "Group A"
            };
            groupManager.Create(groupA);
            var groupB = new Group()
            {
                Name = "Group B"
            };
            groupManager.Create(groupB);
            var groupC = new Group()
            {
                Name = "Group C"
            };
            groupManager.Create(groupC);

            groupManager.AddChild(groupA, groupB);
            groupManager.AddChild(groupA, groupC);

            //groupManager.AssignParent(groupB, groupA);
            //groupManager.AssignParent(groupC, groupA);

            var groupChildren = groupManager.GetChildren(groupA.Id);
            foreach (var child in groupChildren)
                Console.WriteLine("Child Name: " + child.Name);
            Assert.IsNotNull(groupChildren);

            //groupManager.Delete(groupA.Id);
        }
Exemplo n.º 2
0
 public void Can_Create_Group()
 {
     var newGroup = new Group()
     {
         Name = "Group A"
     };
     groupManager.Create(newGroup);
     Console.WriteLine("New Group ID: " + newGroup.Id);
     Console.WriteLine("New Group Name: " + newGroup.Name);
     Assert.IsNotNull(newGroup.Id);
 }
Exemplo n.º 3
0
 public void Can_Assign_And_Get_Parent()
 {
     var groupA = new Group()
     {
         Name = "Group A"
     };
     groupManager.Create(groupA);
     var groupD = new Group()
     {
         Name = "Group D"
     };
     groupManager.Create(groupD);
     //var groupA = groupManager.GetByName("Group A");
     groupManager.AssignParent(groupD, groupA);
     var parentGroup = groupManager.GetParent(groupD.Id);
     Console.WriteLine("Parent Name: " + parentGroup.Name);
     Assert.IsNotNull(parentGroup);
 }
        public void Can_Add_User_To_Group()
        {
            var existingUser = userManager.FindByName("testuser");
            if(existingUser != null)
                userManager.Delete(existingUser);

            var existingGroup = groupManager.GetByName("Group A");
            if(existingGroup != null)
                groupManager.Delete(existingGroup.Id);

            var newUser = new User()
            {
                FirstName = "Test",
                LastName = "User",
                EmailConfirmed = true,
                Email = "*****@*****.**",
                UserName = "******"
            };
            userManager.Create(newUser, "password");

            var group = new Group() {Name = "Group A"};
            groupManager.Create(group);

            Assert.IsTrue(groupManager.AddUser(group.Id, newUser.Id));

            var groupUsers = groupManager.GetById(group.Id, new List<string>() {"Users"}).Users;
            Console.WriteLine("Group: " + group.Name + " Has the following assigned Users!");
            foreach (var groupUser in groupUsers)
            {
                Console.WriteLine("UserID: " + groupUser.Id);
                Console.WriteLine("Name: " + groupUser.FirstName + " " + groupUser.LastName);
            }

            userManager.Delete(newUser);
            groupManager.Delete(group.Id);
        }
        public void Can_Get_My_Child_Groups()
        {
            var existingUser = userManager.FindByName("testuser");
            if (existingUser != null)
                userManager.Delete(existingUser);

            var existingGroup = groupManager.GetByName("Group A");
            if (existingGroup != null)
                groupManager.Delete(existingGroup.Id);

            var existingGroup1 = groupManager.GetByName("Group B");
            if (existingGroup1 != null)
                groupManager.Delete(existingGroup1.Id);

            var newUser = new User()
            {
                FirstName = "Test",
                LastName = "User",
                EmailConfirmed = true,
                Email = "*****@*****.**",
                UserName = "******"
            };
            userManager.Create(newUser, "password");

            var group = new Group() { Name = "Group A" };
            groupManager.Create(group);

            var group1 = new Group() {Name = "Group B"};
            groupManager.Create(group1);

            groupManager.AssignParent(group1, group);

            Assert.IsTrue(groupManager.AddUser(group.Id, newUser.Id));

            var userGroups = userManager.GetById(newUser.Id, new List<string>() {"Groups", "Groups.ChildGroups"});
            var allMyGroups = new List<Group>();
            foreach (var myGroup in userGroups.Groups)
            {
                allMyGroups.Add(myGroup);
                allMyGroups.AddRange(myGroup.ChildGroups);
            }

            Console.WriteLine("All My Groups I Can View Below!");
            foreach (var allMyGroup in allMyGroups)
                Console.WriteLine("Group Name: " + allMyGroup.Name);

            userManager.Delete(newUser);
            groupManager.Delete(group.Id);
            groupManager.Delete(group1.Id);
        }
Exemplo n.º 6
0
 public void Can_Delete_Group()
 {
     var groupC = new Group()
     {
         Name = "Group C"
     };
     groupManager.Create(groupC);
     Assert.IsNotNull(groupManager.GetById(groupC.Id));
     Assert.IsTrue(groupManager.Delete(groupC.Id));
     Assert.IsNull(groupManager.GetById(groupC.Id));
 }
Exemplo n.º 7
0
 public void Can_Update_Group()
 {
     var groupB = new Group()
     {
         Name = "Group B"
     };
     groupManager.Create(groupB);
     Console.WriteLine("Initial Group Id: " + groupB.Id);
     Console.WriteLine("Initial Group Name: " + groupB.Name);
     var updatedGroupB = groupManager.GetById(groupB.Id);
     updatedGroupB.Name = "Group B (Updated)";
     groupManager.Update(updatedGroupB);
     Console.WriteLine("Updated Group Id: " + updatedGroupB.Id);
     Console.WriteLine("Updated Group Name: " + updatedGroupB.Name);
     Assert.AreNotEqual(groupB.Name, updatedGroupB.Name);
 }
Exemplo n.º 8
0
 public void Can_Get_Group_By_Name()
 {
     var groupA = new Group()
     {
         Name = "Group A"
     };
     groupManager.Create(groupA);
     Console.WriteLine("Group Name: " + groupManager.GetByName("Group A").Name);
     Assert.IsInstanceOfType(groupA, typeof (Group));
 }
Exemplo n.º 9
0
        public void Can_Get_All_Groups()
        {
            var groupA = new Group()
            {
                Name = "Group A"
            };
            groupManager.Create(groupA);
            var groupB = new Group()
            {
                Name = "Group B"
            };
            groupManager.Create(groupB);

            var allGroups = groupManager.GetAll();

            foreach (var group in allGroups)
                Console.WriteLine("Group Name: " + group.Name);

            Assert.IsNotNull(allGroups);
        }
Exemplo n.º 10
0
        public void Can_Delete_Group_And_Reassign_Parent()
        {
            var groupA = new Group() { Name = "Group A" };
            groupManager.Create(groupA);

            var groupB = new Group() { Name = "Group B" };
            groupManager.Create(groupB);

            var groupC = new Group() { Name = "Group C" };
            groupManager.Create(groupC);

            var groupD = new Group() { Name = "Group D" };
            groupManager.Create(groupD);

            groupManager.AssignParent(groupB, groupA);
            groupManager.AssignParent(groupC, groupA);
            groupManager.AssignParent(groupD, groupC);

            var parentAChildren = groupManager.GetChildren(groupA.Id);
            Console.WriteLine("Root Parent: " + groupA.Name);
            Console.WriteLine();
            foreach (var parentAChild in parentAChildren)
            {
                Console.WriteLine(" --- Top Group ID: " + parentAChild.TopGroupId);
                Console.WriteLine(" --- Parent: " + parentAChild.ParentGroup.Name);
                Console.WriteLine(" --- Name: " + parentAChild.Name);
                Console.WriteLine();
                foreach (var childGroup in parentAChild.ChildGroups)
                {
                    Console.WriteLine(" --- Top Group ID: " + childGroup.TopGroupId);
                    Console.WriteLine(" ----- Parent: " + childGroup.ParentGroup.Name);
                    Console.WriteLine(" ----- Name: " + childGroup.Name);
                    Console.WriteLine();
                }
            }

            groupManager.Delete(groupC.Id);
            Console.WriteLine("Deleting Group C ... ");
            Console.WriteLine();

            parentAChildren = groupManager.GetChildren(groupA.Id);
            Console.WriteLine("Root Parent: " + groupA.Name);
            Console.WriteLine();
            foreach (var parentAChild in parentAChildren)
            {
                Console.WriteLine(" --- Top Group ID: " + parentAChild.TopGroupId);
                Console.WriteLine(" --- Parent: " + parentAChild.ParentGroup.Name);
                Console.WriteLine(" --- Name: " + parentAChild.Name);
                Console.WriteLine();
                foreach (var childGroup in parentAChild.ChildGroups)
                {
                    Console.WriteLine(" --- Top Group ID: " + childGroup.TopGroupId);
                    Console.WriteLine(" ----- Parent: " + childGroup.ParentGroup.Name);
                    Console.WriteLine(" ----- Name: " + childGroup.Name);
                    Console.WriteLine();
                }
            }

            groupManager.Delete(groupA.Id);
            Console.WriteLine("Deleting Group A ... ");

            Console.WriteLine("Top Group ID: " + groupB.TopGroupId);
            Console.WriteLine("Parent Id: " + (groupB.ParentGroupId.HasValue ? groupB.ParentGroupId.Value.ToString() : "No Parent!"));
            Console.WriteLine("Name: " + groupB.Name);
            Console.WriteLine();

            Console.WriteLine("Top Group ID: " + groupD.TopGroupId);
            Console.WriteLine("Parent Id: " + (groupD.ParentGroupId.HasValue ? groupD.ParentGroupId.Value.ToString() : "No Parent!"));
            Console.WriteLine("Name: " + groupD.Name);
            Console.WriteLine();
            //Assert.IsNotNull(groupManager.GetById(groupC.Id));
            //Assert.IsTrue(groupManager.Delete(groupC.Id));
            //Assert.IsNull(groupManager.GetById(groupC.Id));
        }