Пример #1
0
        public static void SetUpDefaultEditWorkspace(Mock<IRemoteAppManagementClient> clientMock, string endUserFeedName)
        {
            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> Setup = null;
            AccountDetailsParameter details = new AccountDetailsParameter()
            {
                AccountInfo = new AccountDetails()
                {
                    EndUserFeedName = endUserFeedName
                }
            };

            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = "34167",
                RequestId = "111-2222-4444"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            Setup = clientMock.Setup(c => c.Account.SetAsync(It.IsAny<AccountDetailsParameter>(), It.IsAny<CancellationToken>()));
            Setup.Returns(Task.Factory.StartNew(() => response));
        }
Пример #2
0
 public TrackingResult(OperationResultWithTrackingId operation)
 {
     TrackingId = operation.TrackingId;
 }
Пример #3
0
        public static int SetUpDefaultRemoteAppTemplateCreate(Mock<IRemoteAppManagementClient> clientMock, string imageName, string id, string region, string vhdPath)
        {
            const int numberOfTemplatesCreated = 1;

            TemplateImageResult response = new TemplateImageResult()
            {
                RequestId = "1111-33444",
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TemplateImage = new TemplateImage()
                {
                    Name = imageName,
                    Status = TemplateImageStatus.UploadPending,
                    Type = TemplateImageType.PlatformImage,
                    RegionList = new List<string>(){
                        region
                    }
                }
            };

            mockTemplates = new List<TemplateImage>()
            {
                new TemplateImage()
                {
                    Name = response.TemplateImage.Name,
                    Status = response.TemplateImage.Status,
                    Id = response.TemplateImage.Id,
                    NumberOfLinkedCollections = response.TemplateImage.NumberOfLinkedCollections,
                    Type = response.TemplateImage.Type,
                    RegionList = response.TemplateImage.RegionList
                }
            };

            OperationResultWithTrackingId responseWithTrackingId = new OperationResultWithTrackingId()
            {
                RequestId = "2222-1111-33424",
                StatusCode = System.Net.HttpStatusCode.OK
            };

            UploadScriptResult responseUpload = new UploadScriptResult()
            {
                 RequestId = "1111-33333-5",
                 StatusCode = System.Net.HttpStatusCode.OK,
                Script = "$i = 1; foreach ($arg in $Args) { echo \"The $i parameter is $arg\"; $i++ }; return $true", // mock script just prints out arguments 
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> SetupStorageTemplate = clientMock.Setup(c => c.TemplateImages.EnsureStorageInRegionAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()));
            SetupStorageTemplate.Returns(Task.Factory.StartNew(() => responseWithTrackingId));

            ISetup<IRemoteAppManagementClient, Task<TemplateImageResult>> SetupSetTemplate = clientMock.Setup(c => c.TemplateImages.SetAsync(It.IsAny<TemplateImageDetails>(), It.IsAny<CancellationToken>()));
            SetupSetTemplate.Returns(Task.Factory.StartNew(() => response));

            ISetup<IRemoteAppManagementClient, Task<UploadScriptResult>> SetupUploadTemplate = clientMock.Setup(c => c.TemplateImages.GetUploadScriptAsync(It.IsAny<CancellationToken>()));
            SetupUploadTemplate.Returns(Task.Factory.StartNew(() => responseUpload));

            return numberOfTemplatesCreated;
        }
Пример #4
0
        public static int SetUpDefaultRemoteAppCollectionCreate(Mock<IRemoteAppManagementClient> clientMock, string collectionName, string region, string billingPlan, string imageName, string description, string customProperties, string trackingId)
        {

            CollectionCreationDetails collectionDetails = new CollectionCreationDetails()
            {
                Name = collectionName,
                PlanName = billingPlan,
                TemplateImageName = imageName,
                Mode = CollectionMode.Apps,
                Region = region,
                Description = description,
                CustomRdpProperty = customProperties
            };
   
            List<Collection> collectionList = new List<Collection>()
            {
                new Collection()
                {
                    Name = collectionDetails.Name,
                    Region = collectionDetails.Region,
                    PlanName = collectionDetails.PlanName,
                    TemplateImageName = collectionDetails.TemplateImageName,
                    Mode = collectionDetails.Mode,
                    Description = collectionDetails.Description,
                    Status = "Active"
                }
            };

            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = trackingId,
                RequestId = "111-2222-4444"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup = clientMock.Setup(c => c.Collections.CreateAsync(It.IsAny<bool>(), It.IsAny <CollectionCreationDetails>(), It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));

            mockCollectionList = collectionList;

            return mockCollectionList.Count;
        }
Пример #5
0
        public static void SetUpDefaultRemoteAppCollectionDelete(Mock<IRemoteAppManagementClient> clientMock, string collectionName, string trackingId)
        {
            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = trackingId,
                RequestId = "02111-222-3456"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup = clientMock.Setup(c => c.Collections.DeleteAsync(collectionName, It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));
        }
Пример #6
0
        public static int SetUpDefaultRemoteAppCollectionSet(Mock<IRemoteAppManagementClient> clientMock,string collectionName, string subscriptionId, string billingPlan, string imageName, PSCredential credential, string domainName, string trackingId)
        {

            NetworkCredential cred = credential != null ? credential.GetNetworkCredential() : null;

            CollectionCreationDetails collectionDetails = new CollectionCreationDetails()
            {
                Name = collectionName,
                PlanName = billingPlan,
                TemplateImageName = imageName,
                Mode = CollectionMode.Apps,
                Description = "unit test"
            };

            if (cred != null)
            {
                collectionDetails.AdInfo = new ActiveDirectoryConfig()
                {
                    DomainName = domainName,
                    UserName = cred.UserName,
                    Password = cred.Password
                };
            }

            List<Collection> collectionList = new List<Collection>()
            {
                new Collection()
                {
                    Name = collectionDetails.Name,
                    PlanName = collectionDetails.PlanName,
                    TemplateImageName = collectionDetails.TemplateImageName,
                    Mode = collectionDetails.Mode,
                    Description = collectionDetails.Description,
                    Status = "Active",
                    AdInfo = collectionDetails.AdInfo != null ? collectionDetails.AdInfo : null
                }
            };

            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = trackingId,
                RequestId = "222-3456-789"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup = 
                clientMock.Setup(
                    c => c.Collections.SetAsync(
                            collectionName, 
                            It.IsAny<bool>(), 
                            It.IsAny<bool>(), 
                            It.IsAny<CollectionUpdateDetails>(), 
                            It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));

            mockCollectionList = collectionList;

           return mockCollectionList.Count;
        }
Пример #7
0
        public static int SetUpDefaultRemoteAppAddVNet(Mock<IRemoteAppManagementClient> clientMock, VNetParameter vNetDetails)
        {
            List<VNet> vnetList = new List<VNet>()
            {
                new VNet()
                {
                    Region = vNetDetails.Region,
                    VnetAddressSpaces = vNetDetails.VnetAddressSpaces,
                    LocalAddressSpaces = vNetDetails.LocalAddressSpaces,
                    DnsServers = vNetDetails.DnsServers,
                    VpnAddress = vNetDetails.VpnAddress,
                    GatewayType = vNetDetails.GatewayType
                }
            };

            mockVNetList = vnetList;

            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = "12345",
                RequestId = "111-2222-4444"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup =
                clientMock.Setup(c => c.VNet.CreateOrUpdateAsync(It.IsAny<string>(), It.IsAny<VNetParameter>(), It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));

            return mockVNetList.Count;
        }
Пример #8
0
        public static void SetUpDefaultRemoteAppRemoveVNet(Mock<IRemoteAppManagementClient> clientMock, string name)
        {
            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = "225986",
                RequestId = "6233-2222-4444"
            };

            mockTrackingId = new List<TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup =
                clientMock.Setup(c => c.VNet.DeleteAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));
        }