public void ShouldAddAndRemoveAndroidMAMGroupsForPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests"))
            {
                //Initialize aadClient if the test mode is not Playback
                AADClientHelper aadClient = null;
                if (HttpMockServer.Mode != HttpRecorderMode.Playback)
                {
                    aadClient = new AADClientHelper();
                }

                var client = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                //Create a policy
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneAndroidPolicy);
                var    payload      = DefaultAndroidPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated1 = client.Android.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Get groups for tenant
                    var adGroup = TestContextHelper.GetAdGroupFromTestContext("adGroup");

                    //Add group for the policy
                    var groupPayload1 = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(client, LinkType.GroupType, adGroup);
                    client.Android.AddGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup, groupPayload1);

                    //Get groups for the policy
                    var groups = client.Android.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 1, string.Format("Expected groups.Count == 1 and actual:{0}", groups.Count));

                    //Remove groups from the policy
                    client.Android.DeleteGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup);

                    //Get groups for the policy & verify groups are removed.
                    groups = client.Android.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 0, string.Format("Expected groups.Count == 0 but actual groups.Count = {0}", groups.Count));
                }
                finally
                {
                    client.Android.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }
        public void ShouldAddAndRemoveiOSMAMGroupsForPolicy()
        {
            using (MockContext context = MockContext.Start("Microsoft.Azure.Management.Intune.Tests.ScenarioTests.GroupScenarioTests"))
            {
                var client = IntuneClientHelper.GetIntuneResourceManagementClient(context);
                //Create a policy
                string policyName   = TestContextHelper.GetValueFromTestContext(Guid.NewGuid, Guid.Parse, "IntunePolicy").ToString();
                string friendlyName = TestUtilities.GenerateName(IntuneConstants.IntuneiOSPolicy);
                var    payload      = DefaultiOSPolicy.GetPayload(friendlyName);
                try
                {
                    var policyCreated1 = client.Ios.CreateOrUpdateMAMPolicy(
                        IntuneClientHelper.AsuHostName,
                        policyName,
                        payload);

                    //Get groups for tenant
                    var adGroup = TestContextHelper.GetAdGroupFromTestContext("adGroup");

                    //Add group for the policy
                    var groupPayload1 = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(client, LinkType.GroupType, adGroup);
                    client.Ios.AddGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup, groupPayload1);

                    //Get groups for the policy
                    var groups = client.Ios.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 1, string.Format("Expected groups.Count == 1 and actual:{0}", groups.Count));

                    //Remove groups for the policy
                    client.Ios.DeleteGroupForMAMPolicy(IntuneClientHelper.AsuHostName, policyName, adGroup);

                    //Get groups for the policy & verify unlinking
                    groups = client.Ios.GetGroupsForMAMPolicy(IntuneClientHelper.AsuHostName, policyName).ToList();
                    Assert.True(groups.Count == 0, string.Format("Expected groups.Count == 0 and actual:{0}", groups.Count));
                }
                finally
                {
                    client.Ios.DeleteMAMPolicy(IntuneClientHelper.AsuHostName, policyName);
                }
            }
        }