public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, slot, serviceName); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; }; channel.GetDeploymentBySlotThunk = ar => { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0]; Assert.IsFalse(statusUpdated); Assert.IsTrue(resultMessage.Contains(expectedMessage)); Assert.IsTrue(((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline.Count.Equals(0)); } }
public void SetDeploymentStatusProcessSetStatusToActualStatusTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Suspended; string resultMessage; string expectedMessage = string.Format(Resources.DeploymentAlreadyInState, slot, serviceName, currentStatus); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; }; channel.GetDeploymentBySlotThunk = ar => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = currentStatus}; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0]; Assert.IsFalse(statusUpdated); Assert.IsTrue(resultMessage.Contains(expectedMessage)); } }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Running; bool statusUpdated = false; Deployment expectedDeployment = new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => expectedDeployment; }; channel.GetDeploymentBySlotThunk = ar => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = currentStatus}; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.PassThru = true; deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsTrue(statusUpdated); Deployment actual = ((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline[0] as Deployment; Assert.AreEqual<string>(expectedDeployment.Name, actual.Name); Assert.AreEqual<string>(expectedDeployment.Status, actual.Status); Assert.AreEqual<string>(expectedDeployment.DeploymentSlot, actual.DeploymentSlot); } }