public void AddIntuneAndroidMAMPolicyAppCmdlet_WithValidArgs_Test()
        {  
            // Set up the expected Policy
            var res = new Microsoft.Rest.Azure.AzureOperationResponse();

            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            intuneClientMock.SetupAllProperties();
            intuneClientMock.SetupGet(x => x.BaseUri).Returns(new Uri("http://expectedBaseUri"));
           
            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.AddAppForMAMPolicyWithHttpMessagesAsync(
                    expectedLocation.HostName,
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<MAMPolicyAppIdOrGroupIdPayload>(),
                    It.IsAny<Dictionary<string, List<string>>>(),
                    It.IsAny<CancellationToken>()))
               .Returns(Task.FromResult(res));
                         
            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(() => true);

            // Set cmdline args and execute the cmdlet
            this.cmdlet.ExecuteCmdlet();            
        }
        public void AddIntuneAndroidMAMPolicyGroupCmdlet_WithValidArgs_Test()
        {
            // Set up the expected Policy
            var res = new Microsoft.Rest.Azure.AzureOperationResponse();

            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            intuneClientMock.SetupAllProperties();
            intuneClientMock.SetupGet(x => x.BaseUri).Returns(new Uri("http://expectedBaseUri"));

            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.AddGroupForMAMPolicyWithHttpMessagesAsync(
                                       expectedLocation.HostName,
                                       It.IsAny <string>(),
                                       It.IsAny <string>(),
                                       It.IsAny <MAMPolicyAppIdOrGroupIdPayload>(),
                                       It.IsAny <Dictionary <string, List <string> > >(),
                                       It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(res));

            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            // Set cmdline args and execute the cmdlet
            this.cmdlet.ExecuteCmdlet();
        }
示例#3
0
        public void SetIntuneAndroidMAMPolicyCmdlet_WithInValidArgs_Test()
        {
            // Set-up the expected Policy
            var resPolicy = new AzureOperationResponse <AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {
                FriendlyName = "expectedPolicyFriendlyName",
            };

            resPolicy.Body = expectedMAMPolicy;

            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.PatchMAMPolicyWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <AndroidMAMPolicy>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(resPolicy));

            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            // Set the cmdline args and Execute the cmdlet
            this.cmdlet.FriendlyName = "expectedPolicyFriendlyName";
            this.cmdlet.Force        = true;
            this.cmdlet.PinNumRetry  = -1;

            try
            {
                this.cmdlet.ExecuteCmdlet();
            }
            catch (Exception e)
            {
                // Verify the result
                Assert.IsType <PSArgumentOutOfRangeException>(e);
                commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Never());
            }
        }
        /// <summary>
        /// Prepares iOS Policy body for the new policy request
        /// </summary>
        /// <returns>policy request body</returns>
        private AndroidMAMPolicy PrepareAndroidPolicyBody()
        {
            var policyBody = new AndroidMAMPolicy()
            {
                FriendlyName          = this.FriendlyName,
                Description           = this.Description,
                AppSharingFromLevel   = this.AppSharingFromLevel.ToString(),
                AppSharingToLevel     = this.AppSharingToLevel.ToString(),
                Authentication        = this.Authentication.ToString(),
                ClipboardSharingLevel = this.ClipboardSharingLevel.ToString(),
                DataBackup            = this.DataBackup.ToString(),
                FileSharingSaveAs     = this.FileSharingSaveAs.ToString(),
                Pin                         = this.Pin.ToString(),
                PinNumRetry                 = this.PinNumRetry,
                DeviceCompliance            = this.DeviceCompliance.ToString(),
                ManagedBrowser              = this.ManagedBrowser.ToString(),
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(this.AccessRecheckOfflineTimeout.Value),
                AccessRecheckOnlineTimeout  = TimeSpan.FromMinutes(this.AccessRecheckOnlineTimeout.Value),
                OfflineWipeTimeout          = TimeSpan.FromDays(this.OfflineWipeTimeout.Value),
                FileEncryption              = this.FileEncryption.ToString(),
                ScreenCapture               = this.ScreenCapture.ToString()
            };

            return(policyBody);
        }
 /// <summary>
 /// Creates Or Updates Android MAM Policy.
 /// </summary>
 public AndroidMAMPolicy CreateOrUpdateAndroidMAMPolicy(string hostName, string policyId, AndroidMAMPolicy policyParams)
 {
     if (this.Initialized)
     {
         AndroidMAMPolicy androidPolicy = this.IntuneClient.Android.CreateOrUpdateMAMPolicy(hostName, policyId, policyParams);
         return(androidPolicy);
     }
     else
     {
         throw new InvalidOperationException(Resources.NotInitializedErrorMessage);
     }
 }
示例#6
0
        /// <summary>
        /// Prepares iOS Policy body for the new policy request
        /// </summary>
        /// <returns>policy request body</returns>
        private AndroidMAMPolicy PrepareAndriodPolicyBody()
        {
            TimeSpan?accessRecheckOfflineTimeout = null, accessRecheckOnlineTimeout = null, offlineWipeTimeout = null;

            if (AccessRecheckOfflineTimeout.HasValue)
            {
                accessRecheckOfflineTimeout = TimeSpan.FromMinutes(AccessRecheckOfflineTimeout.Value);
            }

            if (AccessRecheckOnlineTimeout.HasValue)
            {
                accessRecheckOnlineTimeout = TimeSpan.FromMinutes(AccessRecheckOnlineTimeout.Value);
            }

            if (OfflineWipeTimeout.HasValue)
            {
                offlineWipeTimeout = TimeSpan.FromDays(OfflineWipeTimeout.Value);
            }

            var policyBody = new AndroidMAMPolicy()
            {
                FriendlyName          = this.FriendlyName,
                Description           = this.Description,
                AppSharingFromLevel   = this.AppSharingFromLevel.HasValue ? AppSharingFromLevel.ToString() : null,
                AppSharingToLevel     = this.AppSharingToLevel.HasValue ? this.AppSharingToLevel.ToString() : null,
                Authentication        = this.Authentication.HasValue ? this.Authentication.ToString() : null,
                ClipboardSharingLevel = this.ClipboardSharingLevel.HasValue ? this.ClipboardSharingLevel.ToString() : null,
                DataBackup            = this.DataBackup.HasValue ? this.DataBackup.ToString() : null,
                FileSharingSaveAs     = this.FileSharingSaveAs.HasValue ? this.FileSharingSaveAs.ToString() : null,
                Pin                         = this.Pin.HasValue ? this.Pin.ToString() : null,
                PinNumRetry                 = this.PinNumRetry,
                DeviceCompliance            = this.DeviceCompliance.HasValue ? this.DeviceCompliance.ToString() : null,
                ManagedBrowser              = this.ManagedBrowser.HasValue ? this.ManagedBrowser.ToString() : null,
                AccessRecheckOfflineTimeout = accessRecheckOfflineTimeout,
                AccessRecheckOnlineTimeout  = accessRecheckOnlineTimeout,
                OfflineWipeTimeout          = offlineWipeTimeout,
                FileEncryption              = this.FileEncryption.HasValue? this.FileEncryption.ToString():null,
                ScreenCapture               = this.ScreenCapture.HasValue?this.ScreenCapture.ToString():null
            };

            return(policyBody);
        }
        public void NewIntuneAndroidMAMPolicyCmdlet_WithDefaultArgs_Test()
        {
            // Set expected Policy object
            var resPolicy = new AzureOperationResponse<AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {   
                FriendlyName = "expectedPolicyFriendlyName",
                PinNumRetry = IntuneConstants.DefaultPinNumRetry,
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(IntuneConstants.DefaultAccessRecheckOfflineTimeout),
                AccessRecheckOnlineTimeout = TimeSpan.FromMinutes(IntuneConstants.DefaultAccessRecheckOnlineTimeout),
                OfflineWipeTimeout = TimeSpan.FromDays(IntuneConstants.DefaultOfflineWipeTimeout),
            };
          
            resPolicy.Body = expectedMAMPolicy;

            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            // Set up mock methods
            intuneClientMock.Setup(f => f.Android.CreateOrUpdateMAMPolicyWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<AndroidMAMPolicy>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
                .Returns(Task.FromResult(resPolicy)).Callback((string hostName, string s, AndroidMAMPolicy pObj, Dictionary<string, List<string>> dict, CancellationToken cTkn ) => { actualPolicyObj = pObj; });
            
            // Mock the PowerShell RunTime method
            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(() => true);
              
            // Set the cmdline args and Execute the cmdlet            
            this.cmdlet.FriendlyName = expectedMAMPolicy.FriendlyName;

            this.cmdlet.ExecuteCmdlet();
            
            // Verify the params which are set with Default values
            Assert.Equal(expectedMAMPolicy.FriendlyName, actualPolicyObj.FriendlyName);
            Assert.Equal(expectedMAMPolicy.Name, actualPolicyObj.Id);
            Assert.Equal(expectedMAMPolicy.Id, actualPolicyObj.Name);
            Assert.Equal(expectedMAMPolicy.PinNumRetry, actualPolicyObj.PinNumRetry);        
            Assert.Equal(expectedMAMPolicy.OfflineWipeTimeout, actualPolicyObj.OfflineWipeTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOfflineTimeout, actualPolicyObj.AccessRecheckOfflineTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOnlineTimeout, actualPolicyObj.AccessRecheckOnlineTimeout);

            commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Once());        
        }
示例#8
0
        public void NewIntuneAndroidMAMPolicyCmdlet_WithDefaultArgs_Test()
        {
            // Set expected Policy object
            var resPolicy = new AzureOperationResponse <AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {
                FriendlyName = "expectedPolicyFriendlyName",
                PinNumRetry  = IntuneConstants.DefaultPinNumRetry,
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(IntuneConstants.DefaultAccessRecheckOfflineTimeout),
                AccessRecheckOnlineTimeout  = TimeSpan.FromMinutes(IntuneConstants.DefaultAccessRecheckOnlineTimeout),
                OfflineWipeTimeout          = TimeSpan.FromDays(IntuneConstants.DefaultOfflineWipeTimeout),
            };

            resPolicy.Body = expectedMAMPolicy;

            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            // Set up mock methods
            intuneClientMock.Setup(f => f.Android.CreateOrUpdateMAMPolicyWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <AndroidMAMPolicy>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(resPolicy)).Callback((string hostName, string s, AndroidMAMPolicy pObj, Dictionary <string, List <string> > dict, CancellationToken cTkn) => { actualPolicyObj = pObj; });

            // Mock the PowerShell RunTime method
            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            // Set the cmdline args and Execute the cmdlet
            this.cmdlet.FriendlyName = expectedMAMPolicy.FriendlyName;

            this.cmdlet.ExecuteCmdlet();

            // Verify the params which are set with Default values
            Assert.Equal(expectedMAMPolicy.FriendlyName, actualPolicyObj.FriendlyName);
            Assert.Equal(expectedMAMPolicy.Name, actualPolicyObj.Id);
            Assert.Equal(expectedMAMPolicy.Id, actualPolicyObj.Name);
            Assert.Equal(expectedMAMPolicy.PinNumRetry, actualPolicyObj.PinNumRetry);
            Assert.Equal(expectedMAMPolicy.OfflineWipeTimeout, actualPolicyObj.OfflineWipeTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOfflineTimeout, actualPolicyObj.AccessRecheckOfflineTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOnlineTimeout, actualPolicyObj.AccessRecheckOnlineTimeout);

            commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Once());
        }
        public void SetIntuneAndroidMAMPolicyCmdlet_WithValidArgs_Test()
        {  
            // Set up the expected Policy
            var resPolicy = new AzureOperationResponse<AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {
                FriendlyName = "expectedPolicyFriendlyName",              
                OfflineWipeTimeout = TimeSpan.FromDays(100),
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(2),
                AccessRecheckOnlineTimeout = TimeSpan.FromMinutes(3),
            };

            resPolicy.Body = expectedMAMPolicy;
            
            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.PatchMAMPolicyWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<AndroidMAMPolicy>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
               .Returns(Task.FromResult(resPolicy)).Callback((string hostName, string s, AndroidMAMPolicy pObj, Dictionary<string, List<string>> dict, CancellationToken cTkn) => { actualPolicyObj = pObj; });
           
            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(() => true);

            // Set cmdline args and Execute the cmdlet
            this.cmdlet.Force = true;
            this.cmdlet.FriendlyName = expectedMAMPolicy.FriendlyName;     
            this.cmdlet.AccessRecheckOfflineTimeout = expectedMAMPolicy.AccessRecheckOfflineTimeout.Value.Minutes;
            this.cmdlet.AccessRecheckOnlineTimeout = expectedMAMPolicy.AccessRecheckOnlineTimeout.Value.Minutes;
            this.cmdlet.OfflineWipeTimeout = expectedMAMPolicy.OfflineWipeTimeout.Value.Days;

            this.cmdlet.ExecuteCmdlet();

            // Verify the result
            Assert.Equal(expectedMAMPolicy.FriendlyName, actualPolicyObj.FriendlyName);
            Assert.Equal(expectedMAMPolicy.OfflineWipeTimeout, actualPolicyObj.OfflineWipeTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOfflineTimeout, actualPolicyObj.AccessRecheckOfflineTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOnlineTimeout, actualPolicyObj.AccessRecheckOnlineTimeout);

            commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Once());
        }
示例#10
0
        public void SetIntuneAndroidMAMPolicyCmdlet_WithValidArgs_Test()
        {
            // Set up the expected Policy
            var resPolicy = new AzureOperationResponse <AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {
                FriendlyName                = "expectedPolicyFriendlyName",
                OfflineWipeTimeout          = TimeSpan.FromDays(100),
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(2),
                AccessRecheckOnlineTimeout  = TimeSpan.FromMinutes(3),
            };

            resPolicy.Body = expectedMAMPolicy;

            AndroidMAMPolicy actualPolicyObj = new AndroidMAMPolicy();

            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.PatchMAMPolicyWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <AndroidMAMPolicy>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(resPolicy)).Callback((string hostName, string s, AndroidMAMPolicy pObj, Dictionary <string, List <string> > dict, CancellationToken cTkn) => { actualPolicyObj = pObj; });

            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            // Set cmdline args and Execute the cmdlet
            this.cmdlet.Force        = true;
            this.cmdlet.FriendlyName = expectedMAMPolicy.FriendlyName;
            this.cmdlet.AccessRecheckOfflineTimeout = expectedMAMPolicy.AccessRecheckOfflineTimeout.Value.Minutes;
            this.cmdlet.AccessRecheckOnlineTimeout  = expectedMAMPolicy.AccessRecheckOnlineTimeout.Value.Minutes;
            this.cmdlet.OfflineWipeTimeout          = expectedMAMPolicy.OfflineWipeTimeout.Value.Days;

            this.cmdlet.ExecuteCmdlet();

            // Verify the result
            Assert.Equal(expectedMAMPolicy.FriendlyName, actualPolicyObj.FriendlyName);
            Assert.Equal(expectedMAMPolicy.OfflineWipeTimeout, actualPolicyObj.OfflineWipeTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOfflineTimeout, actualPolicyObj.AccessRecheckOfflineTimeout);
            Assert.Equal(expectedMAMPolicy.AccessRecheckOnlineTimeout, actualPolicyObj.AccessRecheckOnlineTimeout);

            commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Once());
        }
 /// <summary>
 /// Patch AndroidMAMPolicy.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='hostName'>
 /// Location hostName for the tenant
 /// </param>
 /// <param name='policyName'>
 /// Unique name for the policy
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Create or update an android policy operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AndroidMAMPolicy> PatchMAMPolicyAsync(this IAndroidOperations operations, string hostName, string policyName, AndroidMAMPolicy parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.PatchMAMPolicyWithHttpMessagesAsync(hostName, policyName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Patch AndroidMAMPolicy.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='hostName'>
 /// Location hostName for the tenant
 /// </param>
 /// <param name='policyName'>
 /// Unique name for the policy
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Create or update an android policy operation.
 /// </param>
 public static AndroidMAMPolicy PatchMAMPolicy(this IAndroidOperations operations, string hostName, string policyName, AndroidMAMPolicy parameters)
 {
     return(Task.Factory.StartNew(s => ((IAndroidOperations)s).PatchMAMPolicyAsync(hostName, policyName, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
        public void SetIntuneAndroidMAMPolicyCmdlet_WithInValidArgs_Test()
        {
            // Set-up the expected Policy
            var resPolicy = new AzureOperationResponse<AndroidMAMPolicy>();

            var expectedMAMPolicy = new AndroidMAMPolicy()
            {
                FriendlyName = "expectedPolicyFriendlyName",
            };

            resPolicy.Body = expectedMAMPolicy;

            // Set up the mock methods
            intuneClientMock.Setup(f => f.Android.PatchMAMPolicyWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<AndroidMAMPolicy>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
               .Returns(Task.FromResult(resPolicy));
           
            commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(() => true);

            // Set the cmdline args and Execute the cmdlet
            this.cmdlet.FriendlyName = "expectedPolicyFriendlyName";
            this.cmdlet.Force = true;
            this.cmdlet.PinNumRetry = -1;

            try
            {
                this.cmdlet.ExecuteCmdlet();
            }
            catch (Exception e)
            {
                // Verify the result
                Assert.IsType<PSArgumentOutOfRangeException>(e);
                commandRuntimeMock.Verify(f => f.WriteObject(expectedMAMPolicy), Times.Never());
            }
        }
        /// <summary>
        /// Prepares iOS Policy body for the new policy request
        /// </summary>
        /// <returns>policy request body</returns>
        private AndroidMAMPolicy PrepareAndroidPolicyBody()
        {
            var policyBody = new AndroidMAMPolicy()
            {
                FriendlyName = this.FriendlyName,
                Description = this.Description,
                AppSharingFromLevel = this.AppSharingFromLevel.ToString(),
                AppSharingToLevel = this.AppSharingToLevel.ToString(),
                Authentication = this.Authentication.ToString(),
                ClipboardSharingLevel = this.ClipboardSharingLevel.ToString(),
                DataBackup = this.DataBackup.ToString(),
                FileSharingSaveAs = this.FileSharingSaveAs.ToString(),
                Pin = this.Pin.ToString(),
                PinNumRetry = this.PinNumRetry,
                DeviceCompliance = this.DeviceCompliance.ToString(),
                ManagedBrowser = this.ManagedBrowser.ToString(),
                AccessRecheckOfflineTimeout = TimeSpan.FromMinutes(this.AccessRecheckOfflineTimeout.Value),
                AccessRecheckOnlineTimeout = TimeSpan.FromMinutes(this.AccessRecheckOnlineTimeout.Value),
                OfflineWipeTimeout = TimeSpan.FromDays(this.OfflineWipeTimeout.Value),
                FileEncryption = this.FileEncryption.ToString(),
                ScreenCapture = this.ScreenCapture.ToString()
            };

            return policyBody;
        }
 /// <summary>
 /// Creates Or Updates Android MAM Policy.
 /// </summary>
 public AndroidMAMPolicy CreateOrUpdateAndroidMAMPolicy(string hostName, string policyId, AndroidMAMPolicy policyParams)
 {
     if (this.Initialized)
     {
         AndroidMAMPolicy androidPolicy = this.IntuneClient.Android.CreateOrUpdateMAMPolicy(hostName, policyId, policyParams);
         return androidPolicy;
     }
     else
     {
         throw new InvalidOperationException(Resources.NotInitializedErrorMessage);
     }
 }
        /// <summary>
        /// Prepares iOS Policy body for the new policy request
        /// </summary>
        /// <returns>policy request body</returns>
        private AndroidMAMPolicy PrepareAndriodPolicyBody()
        {
            TimeSpan? accessRecheckOfflineTimeout = null, accessRecheckOnlineTimeout = null, offlineWipeTimeout = null;
            if(AccessRecheckOfflineTimeout.HasValue)
            {
                accessRecheckOfflineTimeout = TimeSpan.FromMinutes(AccessRecheckOfflineTimeout.Value);
            }

            if(AccessRecheckOnlineTimeout.HasValue)
            {
                accessRecheckOnlineTimeout = TimeSpan.FromMinutes(AccessRecheckOnlineTimeout.Value);
            }

            if (OfflineWipeTimeout.HasValue)
            {
                offlineWipeTimeout = TimeSpan.FromDays(OfflineWipeTimeout.Value);
            }
            
            var policyBody = new AndroidMAMPolicy() {             
                FriendlyName = this.FriendlyName,
                Description = this.Description,
                AppSharingFromLevel = this.AppSharingFromLevel.HasValue ? AppSharingFromLevel.ToString() : null,
                AppSharingToLevel = this.AppSharingToLevel.HasValue ? this.AppSharingToLevel.ToString() : null,
                Authentication = this.Authentication.HasValue ? this.Authentication.ToString() : null,
                ClipboardSharingLevel = this.ClipboardSharingLevel.HasValue ? this.ClipboardSharingLevel.ToString() : null,
                DataBackup = this.DataBackup.HasValue ? this.DataBackup.ToString() : null,
                FileSharingSaveAs = this.FileSharingSaveAs.HasValue ? this.FileSharingSaveAs.ToString() : null,
                Pin = this.Pin.HasValue ? this.Pin.ToString() : null,
                PinNumRetry = this.PinNumRetry,
                DeviceCompliance = this.DeviceCompliance.HasValue ? this.DeviceCompliance.ToString() : null,
                ManagedBrowser = this.ManagedBrowser.HasValue ? this.ManagedBrowser.ToString() : null,
                AccessRecheckOfflineTimeout = accessRecheckOfflineTimeout,
                AccessRecheckOnlineTimeout = accessRecheckOnlineTimeout,
                OfflineWipeTimeout = offlineWipeTimeout,
                FileEncryption = this.FileEncryption.HasValue? this.FileEncryption.ToString():null,
                ScreenCapture = this.ScreenCapture.HasValue?this.ScreenCapture.ToString():null
            };

            return policyBody;
        }