public void Validate_ValidChangesInMainArmTemplateParametersFile_Succeeds()
        {
            // Update a parameter value and add an existing parameter.
            var originalFile       = MainArmTemplateParametersFile.ReadFromFileSystem(fileSystem);
            var patchedFileElement = originalFile.RootElement.Patch(
                JsonPatchOperations.Replace("/parameters/linuxAdminUsername/value", "testuser"),
                JsonPatchOperations.Add("/parameters/clusterName", new Dictionary <string, JsonElement>().AsJsonElement()),
                JsonPatchOperations.Add("/parameters/clusterName/value", "aks101cluster"));

            fileSystem.AddFile(originalFile.Path, patchedFileElement.ToFormattedString());

            var fileToValidate = MainArmTemplateParametersFile.ReadFromFileSystem(fileSystem);

            Invoking(() => this.sut.Validate(fileToValidate)).Should().NotThrow();
        }
        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}");
        }