public void AddRemoveMemberTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                //Arrange
                var   client = new GraphTestBase();
                Group group  = client.CreateGroup();
                User  user   = client.CreateUser();

                //test
                client.AddMember(group, user);

                //Verify
                IList <string> groupIds = client.GetMemberGroups(user);
                string         matched  = groupIds.FirstOrDefault(p => p == group.ObjectId);
                Assert.Equal(matched, group.ObjectId);

                //Test
                client.RemoveMember(group, user);

                //Verify
                groupIds = client.GetMemberGroups(user);
                matched  = groupIds.FirstOrDefault(p => p == group.ObjectId);
                Assert.True(string.IsNullOrEmpty(matched));

                //Cleanup
                client.DeleteGroup(group.ObjectId);
                client.DeleteUser(user.ObjectId);
            }
        }
示例#2
0
        public void AddRemoveMemberTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                //Arrange
                var client = new GraphTestBase();
                Group group = client.CreateGroup();
                User user = client.CreateUser();

                //test
                client.AddMember(group, user);

                //Verify
                IList<string> groupIds = client.GetMemberGroups(user);
                string matched = groupIds.FirstOrDefault(p => p == group.ObjectId);
                Assert.Equal(matched, group.ObjectId);

                //Test
                client.RemoveMember(group, user);

                //Verify
                groupIds = client.GetMemberGroups(user);
                matched = groupIds.FirstOrDefault(p => p == group.ObjectId);
                Assert.True(string.IsNullOrEmpty(matched));

                //Cleanup
                client.DeleteGroup(group.ObjectId);
                client.DeleteUser(user.ObjectId);
            }
        }
        public void CreateDeleteGroupTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = new GraphTestBase();

                //Test
                Group group = client.CreateGroup();
                client.DeleteGroup(group.ObjectId);
                //verify the group has been deleted.
                Assert.Throws(typeof(CloudException), () => { client.SearchGroup(group.ObjectId); });
            }
        }
示例#4
0
        public void CreateDeleteGroupTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = new GraphTestBase();

                //Test
                Group group = client.CreateGroup();
                client.DeleteGroup(group.ObjectId);
                //verify the group has been deleted.
                Assert.Throws(typeof(CloudException), () => { client.SearchGroup(group.ObjectId); });
            }
        }
        public void ListPagedGroupsTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var          graphTestBase = new GraphTestBase();
                var          client        = graphTestBase.GraphClient;
                List <Group> createdGroups = new List <Group>();

                for (int i = 0; i < PagenatedItemsCount; i++)
                {
                    createdGroups.Add(graphTestBase.CreateGroup());
                }
                try
                {
                    var firstPage = client.Group.List(null, null);
                    Assert.NotNull(firstPage);
                    Assert.NotNull(firstPage.StatusCode == HttpStatusCode.OK);
                    Assert.NotNull(firstPage.Groups);
                    Assert.NotNull(firstPage.NextLink);

                    var nextPage = client.Group.ListNext(firstPage.NextLink);

                    Assert.NotNull(nextPage.StatusCode == HttpStatusCode.OK);
                    Assert.NotNull(nextPage.Groups);

                    Assert.NotEqual(0, nextPage.Groups.Count());

                    foreach (var group in nextPage.Groups)
                    {
                        Assert.NotNull(group.ObjectId);
                        Assert.NotNull(group.ObjectType);
                    }
                }
                finally
                {
                    foreach (var group in createdGroups)
                    {
                        graphTestBase.DeleteGroup(group.ObjectId);
                    }
                }
            }
        }
示例#6
0
        public void ListPagedGroupsTest()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                var            graphTestBase = new GraphTestBase();
                var            client        = GetGraphClient(context);
                List <ADGroup> createdGroups = new List <ADGroup>();

                for (int i = 0; i < PagenatedItemsCount; i++)
                {
                    createdGroups.Add(graphTestBase.CreateGroup(context));
                }
                try
                {
                    var firstPage = client.Groups.List();
                    Assert.NotNull(firstPage);
                    Assert.NotNull(firstPage.NextPageLink);

                    var nextPage = client.Groups.ListNext(firstPage.NextPageLink);

                    Assert.NotNull(nextPage);
                    Assert.NotEmpty(nextPage);

                    foreach (var group in nextPage)
                    {
                        Assert.NotNull(group.ObjectId);
                        Assert.NotNull(group.ObjectType);
                    }
                }
                finally
                {
                    foreach (var group in createdGroups)
                    {
                        graphTestBase.DeleteGroup(context, group.ObjectId);
                    }
                }
            }
        }
示例#7
0
        public void ListPagedGroupsTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var graphTestBase = new GraphTestBase();
                var client = graphTestBase.GraphClient;
                List<Group> createdGroups = new List<Group>();

                for(int i=0; i<PagenatedItemsCount; i++)
                {
                    createdGroups.Add(graphTestBase.CreateGroup());
                }
                try
                {

                    var firstPage = client.Group.List(null, null);
                    Assert.NotNull(firstPage);
                    Assert.NotNull(firstPage.StatusCode == HttpStatusCode.OK);
                    Assert.NotNull(firstPage.Groups);
                    Assert.NotNull(firstPage.NextLink);

                    var nextPage = client.Group.ListNext(firstPage.NextLink);

                    Assert.NotNull(nextPage.StatusCode == HttpStatusCode.OK);
                    Assert.NotNull(nextPage.Groups);

                    Assert.NotEqual(0, nextPage.Groups.Count());

                    foreach (var group in nextPage.Groups)
                    {
                        Assert.NotNull(group.ObjectId);
                        Assert.NotNull(group.ObjectType);
                    }
                }
                finally
                {
                    foreach (var group in createdGroups)
                    {
                        graphTestBase.DeleteGroup(group.ObjectId);
                    }
                }
            }
        }