public void Validate_MissingDescriptions_ThrowsException() { var mainArmTemplateFile = MainArmTemplateFile.ReadFromFileSystem(this.fileSystem); var mainArmTemplateFileElement = JsonElementFactory.CreateElement(mainArmTemplateFile.Content); var patchedElement = mainArmTemplateFileElement.Patch( JsonPatchOperations.Remove("/parameters/sshRSAPublicKey/metadata/description"), JsonPatchOperations.Remove("/parameters/clusterName/metadata/description"), JsonPatchOperations.Remove("/parameters/osDiskSizeGB/metadata/description"), JsonPatchOperations.Remove("/outputs/controlPlaneFQDN/metadata/description")); fileSystem.AddFile(mainArmTemplateFile.Path, patchedElement.ToJsonString()); var latestArmTemplateFile = MainArmTemplateFile.ReadFromFileSystem(this.fileSystem); var sut = this.CreateDescriptionsValidator(latestArmTemplateFile); FluentActions.Invoking(() => sut.Validate(this.fileToValidate)).Should() .Throw <InvalidModuleFileException>() .WithMessage( $@"The file ""{this.fileToValidate.Path}"" is invalid. Descriptions for the following parameters are missing: - sshRSAPublicKey - clusterName - osDiskSizeGB The file ""{this.fileToValidate.Path}"" is invalid. Descriptions for the following outputs are missing: - controlPlaneFQDN ".ReplaceLineEndings()); }
public void Validate_InvalidChangesInMainArmTemplateParametersFile_ThrowsException() { // Remove a required parameter and add a non-existing parameter. var originalFile = MainArmTemplateParametersFile.ReadFromFileSystem(fileSystem); var patchedFileElement = originalFile.RootElement.Patch( JsonPatchOperations.Remove("/parameters/linuxAdminUsername"), JsonPatchOperations.Add("/parameters/nonExisting", new Dictionary <string, JsonElement>().AsJsonElement()), JsonPatchOperations.Add("/parameters/nonExisting/value", 0)); fileSystem.AddFile(originalFile.Path, patchedFileElement.ToFormattedString()); var fileToValidate = MainArmTemplateParametersFile.ReadFromFileSystem(fileSystem); Invoking(() => this.sut.Validate(fileToValidate)).Should() .Throw <InvalidModuleFileException>() .WithMessage($@"The file ""{fileToValidate.Path}"" is modified or outdated. Please regenerate the file to fix it.{Environment.NewLine}"); }