public void GetIntuneMAMUserDeviceWipe_ReturnsValidItem_Test() { // Set up the expected Policy string deviceWipeResponse = "{\r\n \"name\": \"8693b393-a69c-4d12-a9c8-a1a415884fd2\",\r\n \"type\": \"Microsoft.Intune/locations/users/devices\",\r\n \"properties\": {\r\n \"value\": \"/operationResults/8693b393-a69c-4d12-a9c8-a1a415884fd2?$filter=category eq '8693b393-a69c-4d12-a9c8-a1a415884fd2'\"\r\n }\r\n}"; AzureOperationResponse <WipeDeviceOperationResult> expectedRespose = new AzureOperationResponse <WipeDeviceOperationResult>(); var expectedResult = JsonConvert.DeserializeObject <WipeDeviceOperationResult>(deviceWipeResponse, intuneClientMock.Object.DeserializationSettings); expectedRespose.Body = expectedResult; WipeDeviceOperationResult wipeDeviceOpResult = new WipeDeviceOperationResult(); // Set up the mock methods intuneClientMock.Setup(f => f.WipeMAMUserDeviceWithHttpMessagesAsync( expectedLocation.HostName, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(expectedRespose)); 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.Name = "UserName1"; this.cmdlet.DeviceName = "MyDevice1"; this.cmdlet.ExecuteCmdlet(); // Verify the result commandRuntimeMock.Verify(f => f.WriteObject(expectedResult), Times.Once()); }
public void GetIntuneMAMUserDeviceWipe_ReturnsValidItem_Test() { // Set up the expected Policy string deviceWipeResponse = "{\r\n \"name\": \"8693b393-a69c-4d12-a9c8-a1a415884fd2\",\r\n \"type\": \"Microsoft.Intune/locations/users/devices\",\r\n \"properties\": {\r\n \"value\": \"/operationResults/8693b393-a69c-4d12-a9c8-a1a415884fd2?$filter=category eq '8693b393-a69c-4d12-a9c8-a1a415884fd2'\"\r\n }\r\n}"; AzureOperationResponse<WipeDeviceOperationResult> expectedRespose = new AzureOperationResponse<WipeDeviceOperationResult>(); var expectedResult = JsonConvert.DeserializeObject<WipeDeviceOperationResult>(deviceWipeResponse, intuneClientMock.Object.DeserializationSettings); expectedRespose.Body = expectedResult; WipeDeviceOperationResult wipeDeviceOpResult = new WipeDeviceOperationResult(); // Set up the mock methods intuneClientMock.Setup(f => f.WipeMAMUserDeviceWithHttpMessagesAsync( expectedLocation.HostName, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult(expectedRespose)); 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.Name = "UserName1"; this.cmdlet.DeviceName = "MyDevice1"; this.cmdlet.ExecuteCmdlet(); // Verify the result commandRuntimeMock.Verify(f => f.WriteObject(expectedResult), Times.Once()); }