private static IEnumerable <object[]> GetSuccessData() { yield return(new object[] { MockFileSystemFactory.CreateFileSystemWithEmptyFolder(), MockFileSystemFactory.CreateFileSystemWithEmptyGeneratedFiles(), }); yield return(new object[] { MockFileSystemFactory.CreateFileSystemWithNewFiles(), MockFileSystemFactory.CreateFileSystemWithNewGeneratedFiles(), }); yield return(new object[] { MockFileSystemFactory.CreateFileSystemWithModifiedFiles(), MockFileSystemFactory.CreateFileSystemWithModifiedGeneratedFiles(), }); yield return(new object[] { // Generate valid files should not change the ARM template parameters file. MockFileSystemFactory.CreateFileSystemWithValidFiles(), MockFileSystemFactory.CreateFileSystemWithValidFiles(), }); }
public void Invoke_InvalidFiles_WritesErrorsToConsole() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithInvalidFiles(); var mockMainArmTemplateFileData = fileSystem.GetFile(MainArmTemplateFile.FileName); var processProxy = MockProcessProxyFactory.CreateProcessProxy(callback: () => fileSystem.SetTempFile(mockMainArmTemplateFileData)); var console = new MockConsole().ExpectErrorLines( $@"The file ""{fileSystem.Path.GetFullPath(MainArmTemplateParametersFile.FileName)}"" is invalid: #/parameters/dnsPrefix: Expected 1 matching subschema but found 0 #/parameters/dnsPrefix: Required properties [value] were not present #/parameters/dnsPrefix: Required properties [reference] were not present #/parameters/linuxAdminUsername: Expected 1 matching subschema but found 0 #/parameters/linuxAdminUsername: Required properties [value] were not present #/parameters/linuxAdminUsername: Required properties [reference] were not present ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(MetadataFile.FileName)}"" is invalid: #/description: Value is not longer than or equal to 10 characters #/summary: Value is not longer than or equal to 10 characters ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(ReadmeFile.FileName)}"" is modified or outdated. Please regenerate the file to fix it. ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(VersionFile.FileName)}"" is modified or outdated. Please regenerate the file to fix it. ".ReplaceLineEndings()); Invoke(fileSystem, processProxy, console); console.Verify(); }
public void Invoke_InvalidFiles_WritesErrorsToConsole() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithInvalidFiles(); var mockMainArmTemplateFileData = fileSystem.GetFile(MainArmTemplateFile.FileName); var processProxy = MockProcessProxyFactory.CreateProcessProxy( (args => args.Contains(MainBicepFile.FileName), () => fileSystem.SetTempFile(mockMainArmTemplateFileData)), (args => args.Contains(MainBicepTestFile.FileName), () => fileSystem.SetTempFile(MockInvalidMainTestArmTemplateData))); var console = new MockConsole().ExpectErrorLines( $@"The file ""{fileSystem.Path.GetFullPath(MainBicepFile.FileName)}"" is invalid. Descriptions for the following parameters are missing: - dnsPrefix - servicePrincipalClientSecret The file ""{fileSystem.Path.GetFullPath(MainBicepFile.FileName)}"" is invalid. Descriptions for the following outputs are missing: - controlPlaneFQDN ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath($"test/{MainBicepTestFile.FileName}")}"" is invalid. Could not find tests in the file. Please make sure to add at least one module referencing the main Bicep file. ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(MetadataFile.FileName)}"" is invalid: #/summary: Value is not longer than or equal to 10 characters ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(ReadmeFile.FileName)}"" is modified or outdated. Please regenerate the file to fix it. ".ReplaceLineEndings(), $@"The file ""{fileSystem.Path.GetFullPath(VersionFile.FileName)}"" is invalid: #: Required properties [""$schema"",""version"",""pathFilters""] were not present ".ReplaceLineEndings()); Invoke(fileSystem, processProxy, console); console.Verify(); }
private static IEnumerable <object[]> GetInvalidModulePathData() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); var moduleDirectory = fileSystem.Path.GetFullPath("/modules/FOO/BAR"); fileSystem.MoveDirectory(fileSystem.Directory.GetCurrentDirectory(), moduleDirectory); fileSystem.Directory.SetCurrentDirectory(moduleDirectory); yield return(new object[] { fileSystem, $@"The module path ""FOO{fileSystem.Path.DirectorySeparatorChar}BAR"" in the path ""{moduleDirectory}"" is invalid. All characters in the module path must be in lowercase.{Environment.NewLine}" }); moduleDirectory = fileSystem.Path.GetFullPath("/modules/mymodule"); fileSystem.MoveDirectory(fileSystem.Directory.GetCurrentDirectory(), moduleDirectory); fileSystem.Directory.SetCurrentDirectory(moduleDirectory); yield return(new object[] { fileSystem, $@"The module path ""mymodule"" in the path ""{moduleDirectory}"" is invalid. The module path must be in the format of ""<module-folder>{fileSystem.Path.DirectorySeparatorChar}<module-name>"".{Environment.NewLine}" }); }
public void Invoke_BicepBuildError_ReturnsOne() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithNewlyGeneratedFiles(); var processProxy = MockProcessProxyFactory.CreateProcessProxy(exitCode: 1, standardError: "Build error."); var exitCode = Invoke(fileSystem, processProxy); exitCode.Should().Be(1); }
public void Invoke_InvalidFiles_ReturnsOne() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithInvalidFiles(); var mockMainArmTemplateFileData = fileSystem.GetFile(MainArmTemplateFile.FileName); var processProxy = MockProcessProxyFactory.CreateProcessProxy(callback: () => fileSystem.SetTempFile(mockMainArmTemplateFileData)); var exitCode = Invoke(fileSystem, processProxy); exitCode.Should().Be(1); }
public void Invoke_BicepBuildError_WritesErrorsToConsole() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithNewlyGeneratedFiles(); var processProxy = MockProcessProxyFactory.CreateProcessProxy(exitCode: 1, standardError: "Build error one.\nBuild error two."); var console = new MockConsole().ExpectErrorLines("Build error one.", "Build error two.", $"Failed to build \"{fileSystem.Path.GetFullPath(MainBicepFile.FileName)}\"."); Invoke(fileSystem, processProxy, console); console.Verify(); }
public void Invoke_InvalidFiles_ReturnsOne() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithInvalidFiles(); var mockMainArmTemplateFileData = fileSystem.GetFile(MainArmTemplateFile.FileName); var processProxy = MockProcessProxyFactory.CreateProcessProxy( (args => args.Contains(MainBicepFile.FileName), () => fileSystem.SetTempFile(mockMainArmTemplateFileData)), (args => args.Contains(MainBicepTestFile.FileName), () => fileSystem.SetTempFile(MockInvalidMainTestArmTemplateData))); var exitCode = Invoke(fileSystem, processProxy); exitCode.Should().Be(1); }
private static IEnumerable <object[]> GetSuccessData() { yield return(new object[] { MockFileSystemFactory.CreateFileSystemWithEmptyFolder(), MockFileSystemFactory.CreateFileSystemWithNewlyGeneratedFiles(), }); yield return(new object[] { MockFileSystemFactory.CreateFileSystemWithModifiedFiles(), MockFileSystemFactory.CreateFileSystemWithValidFiles(), }); }
private static IEnumerable <object[]> GetInvalidJsonData() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); fileSystem.AddFile(MetadataFile.FileName, "Invalid JSON content."); yield return(new object[] { fileSystem, $"The metadata file \"{fileSystem.Path.GetFullPath(MetadataFile.FileName)}\" is not a valid JSON file. 'I' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0." }); fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); fileSystem.AddFile(MainArmTemplateParametersFile.FileName, "Invalid JSON content."); yield return(new object[] { fileSystem, $"The ARM template parameters file \"{fileSystem.Path.GetFullPath(MainArmTemplateParametersFile.FileName)}\" is not a valid JSON file. 'I' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0." }); }
private static IEnumerable <object[]> GetEmptyExamplesSectionData() { var fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); var validReadmeFile = ReadmeFile.ReadFromFileSystem(fileSystem); var emptyExamplesSections = new string[] { "## Examples", "## Examples\r\n\r\n", "## Examples\r\n\t ", "## Examples\n \n", }; foreach (var section in emptyExamplesSections) { yield return(new object[] { Regex.Replace(validReadmeFile.Contents, "## Examples.+", section, RegexOptions.Singleline) }); } }
public DiffValidatorTests() { this.fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); this.latestMainArmTemplateFile = MainArmTemplateFile.ReadFromFileSystem(this.fileSystem); this.sut = new DiffValidator(this.fileSystem, MockLoggerFactory.CreateLogger(), this.latestMainArmTemplateFile); }
public DescriptionsValidatorTests() { this.fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles(); this.fileToValidate = MainBicepFile.ReadFromFileSystem(this.fileSystem); }