public void ExtraFiles_Excluded() { // Arrange string filename = "somefilename"; string hash = "somehash"; // This one matches, and shouldn't show in the results MigrationFile expectedMigration = new MigrationFile { Filename = filename, FileHash = hash, }; List<MigrationFile> source = new List<MigrationFile> { expectedMigration }; List<MigrationHistory> dbMigrations = new List<MigrationHistory> { // This one matches new MigrationHistory { Filename = filename, FileHash = hash }, // This one doesn't match new MigrationHistory { Filename = "anotherfile", FileHash = "anotherhash" } }; List<MigrationFile> expectedResults = new List<MigrationFile>(); // empty // Act App app = this.MockServiceLocator.Get<App>(); List<MigrationFile> actualResults = app.MigrationsToAdd( source, dbMigrations ); // Assert Assert.That( actualResults, Is.Not.Null ); Assert.That( actualResults, Is.EquivalentTo( expectedResults ) ); }
public void DifferentHash_Included() { // Arrange string filename = "somefilename"; string hash = "somehash"; MigrationFile expectedMigration = new MigrationFile { Filename = filename, FileHash = hash, }; List<MigrationFile> source = new List<MigrationFile> { expectedMigration }; List<MigrationHistory> dbMigrations = new List<MigrationHistory> { // This one doesn't match by hash new MigrationHistory { Filename = filename, FileHash = hash+"doesn'tmatch" } }; List<MigrationFile> expectedResults = new List<MigrationFile> { expectedMigration }; // Act App app = this.MockServiceLocator.Get<App>(); List<MigrationFile> actualResults = app.MigrationsToAdd( source, dbMigrations ); // Assert Assert.That( actualResults, Is.Not.Null ); Assert.That( actualResults, Is.EquivalentTo( expectedResults ) ); }
public List<MigrationFile> GetAllMigrations( string MigrationFilePath ) { List<string> files = this.migrationFileRepository.GetFilenames( MigrationFilePath ); List<MigrationFile> migrations = new List<MigrationFile>(); foreach ( string f in ( files ?? new List<string>() ) ) { MigrationFile migration = new MigrationFile { Filename = f }; migration.FileContent = this.migrationFileRepository.GetFileContent( MigrationFilePath, migration.Filename ); migration.FileHash = this.hashCalculator.CalculateHash( migration.FileContent ); Tuple<string, string> content = this.migrationFileParser.GetDownScript( migration.FileContent ); migration.DownScript = content.Item1; migration.FileContent = content.Item2; migrations.Add( migration ); } return ( from f in migrations orderby f.Filename select f ).ToList(); }