public void CanParseFile()
        {
            var file        = FileUtility.FirstMatchingFileUpDirectoryTree(@"DatabaseMigration\Test\DatabaseMigrationFiles\11.sql");
            var testSubject = new DatabaseMigrationFileInfo(file);

            Assert.That(testSubject.DatabaseMigrationNumber, Is.EqualTo(11), "Should have gotten number right");
            Assert.That(testSubject.FileContents, Is.EqualTo(FileHelper.ReadAllTextCheckingForProperEncoding(file.FullName)), "Should have read in file correctly");
        }
        public void CanFindDuplicates()
        {
            var m1 = new DatabaseMigrationFileInfo(new FileInfo("001.sql"));
            var m2 = new DatabaseMigrationFileInfo(new FileInfo("1.sql"));
            var m3 = new DatabaseMigrationFileInfo(new FileInfo("2.sql"));
            var m4 = new DatabaseMigrationFileInfo(new FileInfo("0002.sql"));
            var m5 = new DatabaseMigrationFileInfo(new FileInfo("2 Another File.sql"));
            var m6 = new DatabaseMigrationFileInfo(new FileInfo("2 Another File2.sql"));

            var ex = Assert.Catch(() => new DatabaseMigrationFileInfoSet(new List <DatabaseMigrationFileInfo> {
                m1, m2, m3, m4, m5, m6
            }), "Should throw exception because they are duplicates");

            Assert.That(ex.Message, Is.StringContaining("duplicate"), "Should be message about duplicates");
            Trace.WriteLine(ex.Message);
        }
 private static void AssertFileTestCase(string fileName, bool expected)
 {
     Assert.That(DatabaseMigrationFileInfo.IsFileMatch(new FileInfo(fileName)), Is.EqualTo(expected), string.Format("Expected to be {0} for file {1}", expected, fileName));
 }
        private static void AssertGotRightNumber(string filename, int expectedNumber)
        {
            var migration = new DatabaseMigrationFileInfo(new FileInfo(filename));

            Assert.That(migration.DatabaseMigrationNumber, Is.EqualTo(expectedNumber), string.Format("Expected to get number {0} when parsing filename {1}", expectedNumber, filename));
        }
Exemple #5
0
        /// <summary>
        /// Returns other SQL files in alphabetically order
        /// </summary>
        internal List <SqlFileInfo> FindOtherSqlFiles()
        {
            var allFilesInDirectory = _migrationDirectory.EnumerateFiles("*.*", SearchOption.TopDirectoryOnly).Where(x => SqlFileInfo.IsFileMatch(x) && !DatabaseMigrationFileInfo.IsFileMatch(x)).ToList();

            return(allFilesInDirectory.Select(x => new SqlFileInfo(x)).OrderBy(x => x.SqlFile.Name).ToList());
        }