public void CreatesNewPSResourceGroup() { PSCreateResourceGroupParameters expectedParameters = new PSCreateResourceGroupParameters() { ResourceGroupName = resourceGroupName, Location = resourceGroupLocation, TemplateFile = templateFile, DeploymentName = deploymentName, Tag = tags }; PSCreateResourceGroupParameters actualParameters = new PSCreateResourceGroupParameters(); PSResourceGroup expected = new PSResourceGroup() { Location = expectedParameters.Location, ResourceGroupName = expectedParameters.ResourceGroupName, Tags = expectedParameters.Tag }; resourcesClientMock.Setup(f => f.CreatePSResourceGroup(It.IsAny<PSCreateResourceGroupParameters>())) .Returns(expected) .Callback((PSCreateResourceGroupParameters p) => { actualParameters = p; }); cmdlet.Name = expectedParameters.ResourceGroupName; cmdlet.Location = expectedParameters.Location; cmdlet.Tag = expectedParameters.Tag; cmdlet.ExecuteCmdlet(); Assert.Equal(expectedParameters.ResourceGroupName, actualParameters.ResourceGroupName); Assert.Equal(expectedParameters.Location, actualParameters.Location); Assert.Equal(expectedParameters.Tag, actualParameters.Tag); commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once()); }
public override void ExecuteCmdlet() { PSCreateResourceGroupParameters parameters = new PSCreateResourceGroupParameters { ResourceGroupName = Name, Location = Location, Force = Force.IsPresent, Tag = Tag, ConfirmAction = ConfirmAction }; WriteObject(ResourceManagerSdkClient.CreatePSResourceGroup(parameters)); }
/// <summary> /// Creates a new resource group /// </summary> /// <param name="parameters">The create parameters</param> public virtual PSResourceGroup CreatePSResourceGroup(PSCreateResourceGroupParameters parameters) { bool resourceExists = ResourceManagementClient.ResourceGroups.CheckExistence(parameters.ResourceGroupName).Value; ResourceGroup resourceGroup = null; parameters.ConfirmAction(parameters.Force, ProjectResources.ResourceGroupAlreadyExists, ProjectResources.NewResourceGroupMessage, parameters.DeploymentName, () => { resourceGroup = CreateOrUpdateResourceGroup(parameters.ResourceGroupName, parameters.Location, parameters.Tag); WriteVerbose(string.Format(ProjectResources.CreatedResourceGroup, resourceGroup.Name, resourceGroup.Location)); }, () => resourceExists); return resourceGroup != null? resourceGroup.ToPSResourceGroup() : null; }