public static int SetUpDefaultRemoteAppVm(Mock<IRemoteAppManagementClient> clientMock, string collectionName, string vmName, string userUpn, string trackingId) { CollectionVmsListResult response = new CollectionVmsListResult(); OperationResultWithTrackingId restartResponse = new OperationResultWithTrackingId() { StatusCode = System.Net.HttpStatusCode.Accepted, TrackingId = trackingId, RequestId = "111-2222-4444" }; response.Vms = new List<RemoteAppVm>() { new RemoteAppVm() { VirtualMachineName = vmName, LoggedOnUserUpns = { userUpn, "*****@*****.**" } }, new RemoteAppVm() { VirtualMachineName = "testVm2", LoggedOnUserUpns = { "*****@*****.**" } } }; mockVmList = new List<RemoteAppVm>(); foreach (RemoteAppVm vm in response.Vms) { RemoteAppVm mockVm = new RemoteAppVm() { VirtualMachineName = vm.VirtualMachineName, LoggedOnUserUpns = vm.LoggedOnUserUpns }; mockVmList.Add(mockVm); } ISetup<IRemoteAppManagementClient, Task<CollectionVmsListResult>> setup = clientMock.Setup(c => c.Collections.ListVmsAsync(collectionName, It.IsAny<CancellationToken>())); setup.Returns(Task.Factory.StartNew(() => response)); ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setupRestart = clientMock.Setup(c => c.Collections.RestartVmAsync(collectionName, It.IsAny<RestartVmCommandParameter>(),It.IsAny<CancellationToken>())); setupRestart.Returns(Task.Factory.StartNew(() => restartResponse)); return mockVmList.Count; }
public static int SetUpStaleVmObjectsTest(Mock<IRemoteAppManagementClient> clientMock, string collectionName, string[] vmNames) { CollectionVmsListResult response = new CollectionVmsListResult(); ActiveDirectoryConfigResult getAdResponse = new ActiveDirectoryConfigResult() { ActiveDirectoryConfig = new ActiveDirectoryConfig() { DomainName = "contoso.com", OrganizationalUnit = null, UserName = "******", Password = "******" } }; response.Vms = new List<RemoteAppVm>(); foreach(string vmName in vmNames) { response.Vms.Add(new RemoteAppVm() { VirtualMachineName = vmName, LoggedOnUserUpns = { } }); }; mockVmList = new List<RemoteAppVm>(); foreach (RemoteAppVm vm in response.Vms) { RemoteAppVm mockVm = new RemoteAppVm() { VirtualMachineName = vm.VirtualMachineName, LoggedOnUserUpns = vm.LoggedOnUserUpns }; mockVmList.Add(mockVm); } ISetup<IRemoteAppManagementClient, Task<CollectionVmsListResult>> setup = clientMock.Setup(c => c.Collections.ListVmsAsync(collectionName, It.IsAny<CancellationToken>())); setup.Returns(Task.Factory.StartNew(() => response)); ISetup<IRemoteAppManagementClient, Task<ActiveDirectoryConfigResult>> setupGetAd = clientMock.Setup(c => c.Collections.GetAdAsync(collectionName, It.IsAny<CancellationToken>())); setupGetAd.Returns(Task.Factory.StartNew(() => getAdResponse)); return mockVmList.Count; }