public override void ExecuteCmdlet()
        {
            ValidatePSResourceGroupDeploymentParameters parameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                ParameterUri            = TemplateParameterUri
            };

            WriteObject(ResourcesClient.ValidatePSResourceGroupDeployment(parameters, Mode));
        }
Exemple #2
0
        protected override void ProcessRecord()
        {
            ValidatePSResourceGroupDeploymentParameters parameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                ParameterUri            = TemplateParameterUri
            };

            WriteObject(ResourcesClient.ValidatePSResourceGroupDeployment(parameters, Mode));
        }
Exemple #3
0
        public override void ExecuteCmdlet()
        {
            ValidatePSResourceGroupDeploymentParameters parameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                GalleryTemplateIdentity = GalleryTemplateIdentity,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                TemplateVersion         = TemplateVersion,
                StorageAccountName      = StorageAccountName
            };

            WriteObject(ResourcesClient.ValidatePSResourceGroupDeployment(parameters));
        }
        public void ValidatesPSResourceGroupDeploymentWithGalleryTemplate()
        {
            ValidatePSResourceGroupDeploymentParameters expectedParameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                GalleryTemplateIdentity = "sqlServer",
                StorageAccountName      = storageAccountName,
                TemplateVersion         = "1.0"
            };
            ValidatePSResourceGroupDeploymentParameters actualParameters = new ValidatePSResourceGroupDeploymentParameters();
            List <PSResourceManagerError> expected = new List <PSResourceManagerError>()
            {
                new PSResourceManagerError()
                {
                    Code    = "202",
                    Message = "bad input",
                },
                new PSResourceManagerError()
                {
                    Code    = "203",
                    Message = "bad input 2",
                },
                new PSResourceManagerError()
                {
                    Code    = "203",
                    Message = "bad input 3",
                }
            };

            resourcesClientMock.Setup(f => f.ValidatePSResourceGroupDeployment(
                                          It.IsAny <ValidatePSResourceGroupDeploymentParameters>()))
            .Returns(expected)
            .Callback((ValidatePSResourceGroupDeploymentParameters p) => { actualParameters = p; });

            cmdlet.ResourceGroupName       = resourceGroupName;
            cmdlet.GalleryTemplateIdentity = expectedParameters.GalleryTemplateIdentity;
            cmdlet.TemplateVersion         = expectedParameters.TemplateVersion;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(expectedParameters.GalleryTemplateIdentity, actualParameters.GalleryTemplateIdentity);
            Assert.Equal(expectedParameters.TemplateFile, actualParameters.TemplateFile);
            Assert.NotNull(actualParameters.TemplateParameterObject);
            Assert.Equal(expectedParameters.TemplateVersion, actualParameters.TemplateVersion);
            Assert.Equal(null, actualParameters.StorageAccountName);

            commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
        }
Exemple #5
0
        public override void ExecuteCmdlet()
        {
            this.WriteWarning("The Test-AzureResourceGroupTemplate cmdlet is being renamed to Test-AzureResourceGroupDeployment in a future release.");
            if (!string.IsNullOrEmpty(TemplateVersion) || !string.IsNullOrEmpty(StorageAccountName) || !string.IsNullOrEmpty(GalleryTemplateIdentity))
            {
                WriteWarning("The GalleryTemplateIdentity, TemplateVersion and StorageAccountName parameters are being deprecated and will be removed in a future release.");
            }
            ValidatePSResourceGroupDeploymentParameters parameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                ResourceGroupName       = ResourceGroupName,
                GalleryTemplateIdentity = GalleryTemplateIdentity,
                TemplateFile            = TemplateUri ?? this.TryResolvePath(TemplateFile),
                TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject),
                ParameterUri            = TemplateParameterUri,
                TemplateVersion         = TemplateVersion,
                StorageAccountName      = StorageAccountName
            };

            WriteObject(ResourcesClient.ValidatePSResourceGroupDeployment(parameters, Mode));
        }
        public void ValidatesPSResourceGroupDeploymentWithUserTemplate()
        {
            ValidatePSResourceGroupDeploymentParameters expectedParameters = new ValidatePSResourceGroupDeploymentParameters()
            {
                TemplateFile = templateFile
            };
            ValidatePSResourceGroupDeploymentParameters actualParameters = new ValidatePSResourceGroupDeploymentParameters();
            List <PSResourceManagerError> expected = new List <PSResourceManagerError>()
            {
                new PSResourceManagerError()
                {
                    Code    = "202",
                    Message = "bad input",
                },
                new PSResourceManagerError()
                {
                    Code    = "203",
                    Message = "bad input 2",
                },
                new PSResourceManagerError()
                {
                    Code    = "203",
                    Message = "bad input 3",
                }
            };

            resourcesClientMock.Setup(f => f.ValidatePSResourceGroupDeployment(
                                          It.IsAny <ValidatePSResourceGroupDeploymentParameters>(), DeploymentMode.Incremental))
            .Returns(expected)
            .Callback((ValidatePSResourceGroupDeploymentParameters p, DeploymentMode m) => { actualParameters = p; m = DeploymentMode.Incremental; });

            cmdlet.ResourceGroupName = resourceGroupName;
            cmdlet.TemplateFile      = expectedParameters.TemplateFile;

            cmdlet.ExecuteCmdlet();

            Assert.Equal(expectedParameters.TemplateFile, actualParameters.TemplateFile);
            Assert.NotNull(actualParameters.TemplateParameterObject);

            commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
        }