public void AtLeastOneDirectoryMustContainSqlFilesFailsOnEmptyDirs()
        {
            // Setup
            DirectoryInfo directoryInfo =
                DirectoryStructureHelper.CreateValidDatabaseDirStructure("AtLeastOneDirectoryMustContainSqlFilesTest");
            IFileStructurePolicy policy = new MustContainSqlFilePolicy();

            PolicyResult result = policy.Check(directoryInfo);

            // Empty directory. Policy should fail.
            Assert.IsFalse(result.Success);
            Assert.That(result.Messages.Count, Is.EqualTo(1));
        }
        public void AtLeastOneDirectoryMustContainSqlFiles()
        {
            // Setup
            DirectoryInfo directoryInfo =
                DirectoryStructureHelper.CreateValidDatabaseDirStructure("AtLeastOneDirectoryMustContainSqlFilesTest");
            IFileStructurePolicy policy = new MustContainSqlFilePolicy();

            DirectoryStructureHelper.CreateEmptyFile(Path.Combine(directoryInfo.GetDirectories()[1].FullName, "1.0_TestScript.sql"));

            PolicyResult result = policy.Check(directoryInfo);

            // Empty directory. Policy should fail.
            Assert.IsTrue(result.Success);
            Assert.IsEmpty(result.Messages);
        }
        public void AtLeastOneDirectoryMustContainSqlFilesFailsWhenOnlyIgnoredDirectoriesHaveSqlFiles()
        {
            // Arrange
            DirectoryInfo directoryInfo =
                DirectoryStructureHelper.CreateValidDatabaseDirStructure("MustContainSqlFilesFailsWhenOnlyIgnoredDirectoriesHaveSqlFiles");
            IFileStructurePolicy policy = new MustContainSqlFilePolicy();

            // Create sql files ONLY in the ignoredirlist
            foreach (string ignoreDir in Resources.DirectoryIgnoreListStructureTemplateList())
            {
                string fullPath = Path.Combine(directoryInfo.FullName, ignoreDir);
                DirectoryStructureHelper.CreateEmptyFile(Path.Combine(fullPath, "1.0.0_IgnoreMe.sql"));
            }

            // Act
            PolicyResult result = policy.Check(directoryInfo);

            // Assert
            // Empty directory. Policy should fail.
            Assert.IsFalse(result.Success);
            Assert.That(result.Messages.Count, Is.EqualTo(1));
        }