Exemple #1
0
        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}"
            });
        }
        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_ValidFiles_ReturnsZero()
        {
            var fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles();
            var mockMainArmTemplateFileData = fileSystem.GetFile(MainArmTemplateFile.FileName);
            var processProxy = MockProcessProxyFactory.CreateProcessProxy(callback: () => fileSystem.SetTempFile(mockMainArmTemplateFileData));

            var exitCode = Invoke(fileSystem, processProxy);

            exitCode.Should().Be(0);
        }
Exemple #4
0
        public void Invoke_ValidFiles_ReturnsZero()
        {
            var fileSystem = MockFileSystemFactory.CreateFileSystemWithValidFiles();
            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(MockValidMainTestArmTemplateData)));

            var exitCode = Invoke(fileSystem, processProxy);

            exitCode.Should().Be(0);
        }
        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."
            });
        }
Exemple #7
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)
                });
            }
        }
Exemple #8
0
 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);
 }