Exemplo n.º 1
0
        public static void SetUpDefaultRemoteAppUploadScriptTemplate(Mock<IRemoteAppManagementClient> clientMock)
        {

            UploadScriptResult response = new UploadScriptResult()
            {
                RequestId = "1111-33333-5",
                StatusCode = System.Net.HttpStatusCode.OK,
                Script = "Write-Output 'Mock Script'"
            };

            mockTemplateScript = new string(response.Script.ToCharArray());

            ISetup<IRemoteAppManagementClient, Task<UploadScriptResult>> SetupUploadTemplate = clientMock.Setup(c => c.TemplateImages.GetUploadScriptAsync(It.IsAny<CancellationToken>()));
            SetupUploadTemplate.Returns(Task.Factory.StartNew(() => response));
        }
Exemplo n.º 2
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;
        }