예제 #1
0
        public void TestUpgradeCloudServiceFromAPackage()
        {
            clientMocks.ComputeManagementClientMock.Setup(
                c =>
                c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>()))
            .Returns(Tasks.FromResult(new OperationResponse
            {
                RequestId  = "request001",
                StatusCode = HttpStatusCode.OK
            }));

            clientMocks.ComputeManagementClientMock.Setup(
                c =>
                c.Deployments.UpgradeBySlotAsync(It.IsAny <string>(), DeploymentSlot.Production,
                                                 It.IsAny <DeploymentUpgradeParameters>(),
                                                 It.IsAny <CancellationToken>()))
            .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002")));


            clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny <CancellationToken>()))
            .Returns(Tasks.FromResult(new LocationsListResponse
            {
                Locations =
                {
                    new LocationsListResponse.Location {
                        DisplayName = "East US", Name = "EastUS"
                    }
                }
            }));

            using (var files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Setup
                string packageName = serviceName;
                string package, configuration;
                files.CreateDirectoryWithPrebuiltPackage(packageName, out package, out configuration);
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                // Execute
                ExecuteInTempCurrentDirectory(Path.GetDirectoryName(package),
                                              () => client.PublishCloudService(package, configuration, null, null, null, null, null, false, false));

                // Verify
                clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName,
                                                                                                     DeploymentSlot.Production, It.IsAny <DeploymentUpgradeParameters>(), It.IsAny <CancellationToken>()), Times.Once);
            }
        }
        public void TestUpgradeCloudServiceFromAPackage()
        {
            clientMocks.ComputeManagementClientMock.Setup(
                c =>
                c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>()))
                .Returns(Tasks.FromResult(new OperationResponse
                {
                    RequestId = "request001",
                    StatusCode = HttpStatusCode.OK
                }));

            clientMocks.ComputeManagementClientMock.Setup(
                c =>
                c.Deployments.UpgradeBySlotAsync(It.IsAny<string>(), DeploymentSlot.Production,
                                                 It.IsAny<DeploymentUpgradeParameters>(),
                                                 It.IsAny<CancellationToken>()))
                .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002")));


            clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()))
                .Returns(Tasks.FromResult(new LocationsListResponse
                {
                    Locations =
                    {
                        new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"}
                    }
                }));

            using (var files = new FileSystemHelper(this) { EnableMonitoring = true })
            {
                // Setup
                string packageName = serviceName;
                string package, configuration;
                files.CreateDirectoryWithPrebuiltPackage(packageName, out package, out configuration);
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                // Execute
                ExecuteInTempCurrentDirectory(Path.GetDirectoryName(package),
                    () => client.PublishCloudService(package, configuration, null, null, null, null, null, false, false));

                // Verify
                clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, 
                    DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>()), Times.Once);
            }
        }