Ejemplo n.º 1
0
        public static bool ContainsExpectedResult(List<TemplateImageResult> expectedResult, TemplateImageResult operationResult)
        {
            bool isIdentical = false;
            foreach (TemplateImageResult expected in expectedResult)
            {
                isIdentical = expected.RequestId == operationResult.RequestId;
                isIdentical &= expected.StatusCode == operationResult.StatusCode;
                isIdentical &= expected.TemplateImage.Name == operationResult.TemplateImage.Name;
                isIdentical &= expected.TemplateImage.Status == operationResult.TemplateImage.Status;
                isIdentical &= expected.TemplateImage.Id == operationResult.TemplateImage.Id;
                isIdentical &= expected.TemplateImage.NumberOfLinkedCollections == operationResult.TemplateImage.NumberOfLinkedCollections;
                isIdentical &= expected.TemplateImage.Type == operationResult.TemplateImage.Type;
                if (isIdentical)
                {
                    break;
                }
            }

            return isIdentical;
        }
Ejemplo n.º 2
0
        public static void SetUpDefaultRemoteAppRenameTemplate(Mock<IRemoteAppManagementClient> clientMock, string newName, string id)
        {
            TemplateImageResult response = new TemplateImageResult()
            {
                 StatusCode = System.Net.HttpStatusCode.Accepted,
                 RequestId = "12345",
                 TemplateImage = new TemplateImage()
                 {
                     Id = id,
                     Name = newName,
                     RegionList = new List<string>(){
                        "West US"
                     }
                 }
            };

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

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

            return;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
        public static int SetUpDefaultRemoteAppTemplatesByName(Mock<IRemoteAppManagementClient> clientMock, string imageName)
        {
            TemplateImageResult response = new TemplateImageResult()
            {
                RequestId = "222-1234-9999",
                StatusCode = System.Net.HttpStatusCode.OK,
                TemplateImage = new TemplateImage()
                {
                    Name = imageName,
                    Status = TemplateImageStatus.Ready,
                    Id = "1111",
                    NumberOfLinkedCollections = 2,
                    Type = TemplateImageType.PlatformImage,
                    RegionList = new List<string>(){
                        "West US"
                    }
                }
            };

            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
                }
            };

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

            return mockTemplates.Count;
        }