PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ResourceManager/Intune/Commands.Intune.Test/UnitTests/Policy/GetIntuneAndroidMAMPolicyCmdletTests.cs

https://gitlab.com/jslee1/azure-powershell
C# | 148 lines | 90 code | 24 blank | 34 comment | 0 complexity | 9fa00627dd31e3d09936183725cf6e6f MD5 | raw file
  1. // ----------------------------------------------------------------------------------
  2. //
  3. // Copyright Microsoft Corporation
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // ----------------------------------------------------------------------------------
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Management.Automation;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. using Microsoft.Azure.Management.Intune;
  20. using Microsoft.Azure.Management.Intune.Models;
  21. using Microsoft.Rest.Azure;
  22. using Microsoft.WindowsAzure.Commands.ScenarioTest;
  23. using Moq;
  24. using Newtonsoft.Json;
  25. using Xunit;
  26. using Xunit.Abstractions;
  27. using Microsoft.Azure.ServiceManagemenet.Common.Models;
  28. namespace Microsoft.Azure.Commands.Intune.Test
  29. {
  30. /// <summary>
  31. /// Unit Tests for the GetIntuneAndroidMAMPolicy Cmdlet.
  32. /// </summary>
  33. public class GetIntuneAndroidMAMPolicyCmdletTests
  34. {
  35. private Mock<IIntuneResourceManagementClient> intuneClientMock;
  36. private Mock<ICommandRuntime> commandRuntimeMock;
  37. private GetIntuneAndroidMAMPolicyCmdlet cmdlet;
  38. private Location expectedLocation;
  39. /// <summary>
  40. /// C'tor for GetIntuneAndroidMAMPolicyCmdletTests class.
  41. /// </summary>
  42. public GetIntuneAndroidMAMPolicyCmdletTests(ITestOutputHelper output)
  43. {
  44. XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
  45. commandRuntimeMock = new Mock<ICommandRuntime>();
  46. intuneClientMock = new Mock<IIntuneResourceManagementClient>();
  47. cmdlet = new GetIntuneAndroidMAMPolicyCmdlet();
  48. this.cmdlet.CommandRuntime = commandRuntimeMock.Object;
  49. this.cmdlet.IntuneClient = intuneClientMock.Object;
  50. // Set-up mock Location and mock the underlying service API method
  51. AzureOperationResponse<Location> resLocation = new AzureOperationResponse<Location>();
  52. expectedLocation = new Location("mockHostName");
  53. resLocation.Body = expectedLocation;
  54. intuneClientMock.Setup(f => f.GetLocationByHostNameWithHttpMessagesAsync(It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
  55. .Returns(Task.FromResult(resLocation));
  56. }
  57. /// <summary>
  58. /// Test to return valid item.
  59. /// </summary>
  60. [Fact]
  61. [Trait(Category.AcceptanceType, Category.CheckIn)]
  62. public void GetAndroidPolicies_ReturnsValidItem_Test()
  63. {
  64. // Set up the expected Policy
  65. string expectedPolicyResBody = "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/05207a60-6afd-4fd0-a8a8-e4e54bc11aa5\",\r\n \"name\": \"05207a60-6afd-4fd0-a8a8-e4e54bc11aa5\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy4872\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:29:48.0885169\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/0f85f3de-172b-4867-9c8c-61dcf8798515\",\r\n \"name\": \"0f85f3de-172b-4867-9c8c-61dcf8798515\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy542\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:30:56.7433738\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/1e5326cd-1d14-45df-a2b6-217e89a51b84\",\r\n \"name\": \"1e5326cd-1d14-45df-a2b6-217e89a51b84\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy2587\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:29:50.5728801\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/485cacb6-4c14-4530-b9eb-319f380201de\",\r\n \"name\": \"485cacb6-4c14-4530-b9eb-319f380201de\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy3818\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:31:02.853748\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/ab511ef4-fae7-4b88-8de1-ebfe8b89775c\",\r\n \"name\": \"ab511ef4-fae7-4b88-8de1-ebfe8b89775c\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy3156\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:11:28.8676537\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/b4a51113-0c80-48f8-a1ec-f18ebff0a4b0\",\r\n \"name\": \"b4a51113-0c80-48f8-a1ec-f18ebff0a4b0\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy8044\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T23:53:00.7365543\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/e3059837-8d02-4dbd-a166-4c620950db3a\",\r\n \"name\": \"e3059837-8d02-4dbd-a166-4c620950db3a\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy67\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T23:53:01.1428402\"\r\n }\r\n }\r\n ]\r\n}";
  66. var expectedRespose = new AzureOperationResponse<IPage<AndroidMAMPolicy>>();
  67. var expectedResultPage = new Page<AndroidMAMPolicy>();
  68. expectedResultPage = JsonConvert.DeserializeObject<Page<AndroidMAMPolicy>>(expectedPolicyResBody, intuneClientMock.Object.DeserializationSettings);
  69. expectedRespose.Body = expectedResultPage;
  70. // Set up the mock methods
  71. intuneClientMock.Setup(f => f.Android.GetMAMPoliciesWithHttpMessagesAsync(
  72. expectedLocation.HostName,
  73. It.IsAny<string>(),
  74. It.IsAny<int?>(),
  75. It.IsAny<string>(),
  76. It.IsAny<Dictionary<string, List<string>>>(),
  77. It.IsAny<CancellationToken>()))
  78. .Returns(Task.FromResult(expectedRespose));
  79. intuneClientMock.Setup(f => f.Android.GetMAMPoliciesNextWithHttpMessagesAsync(
  80. It.IsAny<string>(),
  81. It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
  82. .Returns(Task.FromResult(expectedRespose));
  83. commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
  84. .Returns(() => true);
  85. // Set cmdline args and execute the cmdlet
  86. this.cmdlet.ExecuteCmdlet();
  87. // Verify the result
  88. commandRuntimeMock.Verify(f => f.WriteObject(expectedResultPage, true), Times.Once());
  89. }
  90. /// <summary>
  91. /// Test to return 0 item.
  92. /// </summary>
  93. [Fact]
  94. [Trait(Category.AcceptanceType, Category.CheckIn)]
  95. public void GetAndroidPolicies_ReturnsNoItem_Test()
  96. {
  97. // Set up the expected Policy
  98. string expectedPolicyResBody = "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/05207a60-6afd-4fd0-a8a8-e4e54bc11aa5\",\r\n \"name\": \"05207a60-6afd-4fd0-a8a8-e4e54bc11aa5\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy4872\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:29:48.0885169\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/0f85f3de-172b-4867-9c8c-61dcf8798515\",\r\n \"name\": \"0f85f3de-172b-4867-9c8c-61dcf8798515\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy542\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:30:56.7433738\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/1e5326cd-1d14-45df-a2b6-217e89a51b84\",\r\n \"name\": \"1e5326cd-1d14-45df-a2b6-217e89a51b84\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy2587\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:29:50.5728801\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/485cacb6-4c14-4530-b9eb-319f380201de\",\r\n \"name\": \"485cacb6-4c14-4530-b9eb-319f380201de\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy3818\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:31:02.853748\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/ab511ef4-fae7-4b88-8de1-ebfe8b89775c\",\r\n \"name\": \"ab511ef4-fae7-4b88-8de1-ebfe8b89775c\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy3156\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T20:11:28.8676537\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/b4a51113-0c80-48f8-a1ec-f18ebff0a4b0\",\r\n \"name\": \"b4a51113-0c80-48f8-a1ec-f18ebff0a4b0\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy8044\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T23:53:00.7365543\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Intune/locations/fef.dmsua01/IosPolicies/e3059837-8d02-4dbd-a166-4c620950db3a\",\r\n \"name\": \"e3059837-8d02-4dbd-a166-4c620950db3a\",\r\n \"type\": \"Microsoft.Intune/locations/IosPolicies\",\r\n \"properties\": {\r\n \"screenCapture\": \"allow\",\r\n \"fileEncryption\": \"required\",\r\n \"friendlyName\": \"IntuneIosPolicy67\",\r\n \"description\": \"New Ios Policy\",\r\n \"accessRecheckOfflineTimeout\": \"P0DT12H00M\",\r\n \"accessRecheckOnlineTimeout\": \"P0DT00H30M\",\r\n \"appSharingFromLevel\": \"none\",\r\n \"appSharingToLevel\": \"none\",\r\n \"authentication\": \"required\",\r\n \"clipboardSharingLevel\": \"blocked\",\r\n \"dataBackup\": \"allow\",\r\n \"deviceCompliance\": \"enable\",\r\n \"managedBrowser\": \"required\",\r\n \"fileSharingSaveAs\": \"allow\",\r\n \"offlineWipeTimeout\": \"P1D\",\r\n \"pin\": \"required\",\r\n \"pinNumRetry\": 15,\r\n \"numOfApps\": 0,\r\n \"groupStatus\": \"notTargeted\",\r\n \"lastModifiedTime\": \"2015-11-12T23:53:01.1428402\"\r\n }\r\n }\r\n ]\r\n}";
  99. var expectedRespose = new AzureOperationResponse<IPage<AndroidMAMPolicy>>();
  100. IPage<AndroidMAMPolicy> expectedResultPage = new Page<AndroidMAMPolicy>();
  101. expectedResultPage = JsonConvert.DeserializeObject<Page<AndroidMAMPolicy>>(expectedPolicyResBody, intuneClientMock.Object.DeserializationSettings);
  102. expectedRespose.Body = expectedResultPage;
  103. // Set up the mock methods
  104. intuneClientMock.Setup(f => f.Android.GetMAMPoliciesWithHttpMessagesAsync(
  105. expectedLocation.HostName,
  106. It.IsAny<string>(),
  107. It.IsAny<int?>(),
  108. It.IsAny<string>(),
  109. It.IsAny<Dictionary<string, List<string>>>(),
  110. It.IsAny<CancellationToken>()))
  111. .Returns(Task.FromResult(expectedRespose));
  112. intuneClientMock.Setup(f => f.Android.GetMAMPoliciesNextWithHttpMessagesAsync(
  113. It.IsAny<string>(),
  114. It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
  115. .Returns(Task.FromResult(expectedRespose));
  116. commandRuntimeMock.Setup(m => m.ShouldProcess(It.IsAny<string>(), It.IsAny<string>()))
  117. .Returns(() => true);
  118. // Set cmdline args and execute the cmdlet
  119. this.cmdlet.ExecuteCmdlet();
  120. // Verify the result
  121. commandRuntimeMock.Verify(f => f.WriteObject(expectedResultPage, true), Times.Once());
  122. }
  123. }
  124. }