public void GetSepcificResourcesGroupDeployment() { FilterDeploymentOptions options = new FilterDeploymentOptions() { DeploymentName = deploymentName, ResourceGroupName = resourceGroupName }; FilterDeploymentOptions actual = new FilterDeploymentOptions(); List <PSResourceGroupDeployment> result = new List <PSResourceGroupDeployment>(); PSResourceGroupDeployment expected = new PSResourceGroupDeployment() { DeploymentName = deploymentName, CorrelationId = "123", ResourceGroupName = resourceGroupName, Mode = DeploymentMode.Incremental }; result.Add(expected); resourcesClientMock.Setup(f => f.FilterResourceGroupDeployments(It.IsAny <FilterDeploymentOptions>())) .Returns(result) .Callback((FilterDeploymentOptions o) => { actual = o; }); cmdlet.ResourceGroupName = resourceGroupName; cmdlet.Name = deploymentName; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(result, true), Times.Once()); Assert.Equal(options.DeploymentName, actual.DeploymentName); Assert.Equal(options.ExcludedProvisioningStates, actual.ExcludedProvisioningStates); Assert.Equal(options.ProvisioningStates, actual.ProvisioningStates); Assert.Equal(options.ResourceGroupName, actual.ResourceGroupName); }
public static PSResourceGroupDeployment ToPSResourceGroupDeployment(this DeploymentExtended result, string resourceGroup) { PSResourceGroupDeployment deployment = new PSResourceGroupDeployment(); if (result != null) { deployment = CreatePSResourceGroupDeployment(result.Name, resourceGroup, result.Properties); } return(deployment); }
private static PSResourceGroupDeployment CreatePSResourceGroupDeployment( string name, string resourceGroup, DeploymentPropertiesExtended properties) { PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment(); deploymentObject.DeploymentName = name; deploymentObject.ResourceGroupName = resourceGroup; SetDeploymentProperties(deploymentObject, properties); return(deploymentObject); }
private static PSResourceGroupDeployment CreatePSResourceGroupDeployment( DeploymentExtended deployment, string resourceGroup) { PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment { DeploymentName = deployment.Name, ResourceGroupName = resourceGroup, Tags = deployment.Tags == null ? null : new Dictionary <string, string>(deployment.Tags) }; SetDeploymentProperties(deploymentObject, deployment.Properties); return(deploymentObject); }
private static PSResourceGroupDeployment CreatePSResourceGroupDeployment( string name, string gesourceGroup, DeploymentPropertiesExtended properties) { PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment(); deploymentObject.DeploymentName = name; deploymentObject.ResourceGroupName = gesourceGroup; if (properties != null) { deploymentObject.Mode = properties.Mode.Value; deploymentObject.ProvisioningState = properties.ProvisioningState; deploymentObject.TemplateLink = properties.TemplateLink; deploymentObject.Timestamp = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value; deploymentObject.CorrelationId = properties.CorrelationId; if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel)) { deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel; } if (properties.Outputs != null) { Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString()); deploymentObject.Outputs = outputs; } if (properties.Parameters != null) { Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString()); deploymentObject.Parameters = parameters; } if (properties.TemplateLink != null) { deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink); } } return(deploymentObject); }
public void CreatesNewPSResourceGroupDeploymentWithUserTemplate() { PSDeploymentCmdletParameters expectedParameters = new PSDeploymentCmdletParameters() { TemplateFile = templateFile, DeploymentName = deploymentName, }; PSDeploymentCmdletParameters actualParameters = new PSDeploymentCmdletParameters(); PSResourceGroupDeployment expected = new PSResourceGroupDeployment() { Mode = DeploymentMode.Incremental, DeploymentName = deploymentName, CorrelationId = "123", Outputs = new Dictionary <string, DeploymentVariable>() { { "Variable1", new DeploymentVariable() { Value = "true", Type = "bool" } }, { "Variable2", new DeploymentVariable() { Value = "10", Type = "int" } }, { "Variable3", new DeploymentVariable() { Value = "hello world", Type = "string" } } }, Parameters = new Dictionary <string, DeploymentVariable>() { { "Parameter1", new DeploymentVariable() { Value = "true", Type = "bool" } }, { "Parameter2", new DeploymentVariable() { Value = "10", Type = "int" } }, { "Parameter3", new DeploymentVariable() { Value = "hello world", Type = "string" } } }, ProvisioningState = ProvisioningState.Succeeded.ToString(), ResourceGroupName = resourceGroupName, TemplateLink = new TemplateLink() { ContentVersion = "1.0", Uri = "http://mytemplate.com" }, Timestamp = new DateTime(2014, 2, 13) }; resourcesClientMock.Setup(f => f.ExecuteDeployment( It.IsAny <PSDeploymentCmdletParameters>())) .Returns(expected) .Callback((PSDeploymentCmdletParameters p) => { actualParameters = p; }); cmdlet.ResourceGroupName = resourceGroupName; cmdlet.Name = expectedParameters.DeploymentName; cmdlet.TemplateFile = expectedParameters.TemplateFile; cmdlet.ExecuteCmdlet(); Assert.Equal(expectedParameters.DeploymentName, actualParameters.DeploymentName); Assert.Equal(expectedParameters.TemplateFile, actualParameters.TemplateFile); Assert.NotNull(actualParameters.TemplateParameterObject); commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once()); }
public void CreatesNewPSResourceGroupDeploymentWithUserTemplateEmptyRollback() { PSDeploymentCmdletParameters expectedParameters = new PSDeploymentCmdletParameters() { TemplateFile = templateFile, DeploymentName = deploymentName, Tags = new Dictionary <string, string>(this.deploymentTags), OnErrorDeployment = new OnErrorDeployment { Type = OnErrorDeploymentType.LastSuccessful, } }; PSDeploymentCmdletParameters actualParameters = new PSDeploymentCmdletParameters(); PSResourceGroupDeployment expected = new PSResourceGroupDeployment() { Mode = DeploymentMode.Incremental, DeploymentName = deploymentName, CorrelationId = "123", Outputs = new Dictionary <string, DeploymentVariable>() { { "Variable1", new DeploymentVariable() { Value = "true", Type = "bool" } }, { "Variable2", new DeploymentVariable() { Value = "10", Type = "int" } }, { "Variable3", new DeploymentVariable() { Value = "hello world", Type = "string" } } }, Parameters = new Dictionary <string, DeploymentVariable>() { { "Parameter1", new DeploymentVariable() { Value = "true", Type = "bool" } }, { "Parameter2", new DeploymentVariable() { Value = "10", Type = "int" } }, { "Parameter3", new DeploymentVariable() { Value = "hello world", Type = "string" } } }, ProvisioningState = ProvisioningState.Succeeded.ToString(), ResourceGroupName = resourceGroupName, TemplateLink = new TemplateLink() { ContentVersion = "1.0", Uri = "http://mytemplate.com" }, Timestamp = new DateTime(2014, 2, 13), OnErrorDeployment = new OnErrorDeploymentExtended { Type = OnErrorDeploymentType.LastSuccessful, } }; resourcesClientMock.Setup(f => f.ExecuteResourceGroupDeployment( It.IsAny <PSDeploymentCmdletParameters>())) .Returns(expected) .Callback((PSDeploymentCmdletParameters p) => { actualParameters = p; }); cmdlet.ResourceGroupName = resourceGroupName; cmdlet.Name = expectedParameters.DeploymentName; cmdlet.TemplateFile = expectedParameters.TemplateFile; cmdlet.RollbackToLastDeployment = true; cmdlet.Tag = new Hashtable(this.deploymentTags); cmdlet.ExecuteCmdlet(); actualParameters.DeploymentName.Should().Equals(expectedParameters.DeploymentName); actualParameters.TemplateFile.Should().Equals(expectedParameters.TemplateFile); actualParameters.TemplateParameterObject.Should().NotBeNull(); actualParameters.OnErrorDeployment.Should().NotBeNull(); actualParameters.OnErrorDeployment.Type.Should().Equals(expectedParameters.OnErrorDeployment.Type); actualParameters.OnErrorDeployment.DeploymentName.Should().Equals(expectedParameters.OnErrorDeployment.DeploymentName); actualParameters.Tags.Should().NotBeNull(); var differenceTags = actualParameters.Tags .Where(entry => expectedParameters.Tags[entry.Key] != entry.Value); differenceTags.Should().BeEmpty(); commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once()); }