public static IEvolveMetadata AssertSchemaIsErasableWhenEmptySchemaFound(this IEvolveMetadata metadataTable, string schemaName) { metadataTable.Save(MetadataType.EmptySchema, "0", "Empty schema found.", schemaName); Assert.False(metadataTable.CanDropSchema(schemaName), $"[{schemaName}] should not be droppable."); Assert.True(metadataTable.CanEraseSchema(schemaName), $"[{schemaName}] should be erasable."); return(metadataTable); }
public static IEvolveMetadata AssertMetadataTableLockEx(this IEvolveMetadata metadataTable) { Assert.True(metadataTable.TryLock()); Assert.False(metadataTable.TryLock()); Assert.True(metadataTable.ReleaseLock()); return(metadataTable); }
public static IEvolveMetadata AssertVersionedMigrationChecksumUpdate(this IEvolveMetadata metadataTable, int metadataId = 2) { metadataTable.UpdateChecksum(metadataId, "Hi !"); var metadata = metadataTable.GetAllMigrationMetadata().Single(x => x.Id == metadataId); Assert.True(metadata.Checksum == "Hi !", $"Updated checksum should be: Hi!, but found {metadata.Checksum}"); return(metadataTable); }
public static bool IsEvolveInitialized(this IEvolveMetadata metadata) { try { return(metadata.IsExists()); } catch { return(false); } }
public static IEvolveMetadata AssertVersionedMigrationSave(this IEvolveMetadata metadataTable) { metadataTable.SaveMigration(FileMigrationScriptV, true); Assert.True(metadataTable.GetAllMigrationMetadata().Count() == 1, $"1 migration metadata should have been found, instead of {metadataTable.GetAllMigrationMetadata().Count()}."); Assert.True(metadataTable.GetAllRepeatableMigrationMetadata().Count() == 0, $"0 repeatable migration metadata should have been found, instead of {metadataTable.GetAllRepeatableMigrationMetadata().Count()}."); var metadata = metadataTable.GetAllMigrationMetadata().First(); Assert.True(metadata.Version == FileMigrationScriptV.Version, $"Migration metadata version should be: 2.3.1, but found {metadata.Version}."); Assert.True(metadata.Checksum == FileMigrationScriptV.CalculateChecksum(), $"Migration metadata checksum should be: 6C7E36422F79696602E19079534B4076, but found {metadata.Checksum}."); Assert.True(metadata.Description == FileMigrationScriptV.Description, $"Migration metadata description should be: Duplicate migration script, but found {metadata.Description}."); Assert.True(metadata.Name == FileMigrationScriptV.Name, $"Migration metadata name should be: V2_3_1__Duplicate_migration_script.sql, but found {metadata.Name}."); Assert.True(metadata.Success == true, $"Migration metadata success should be: true, but found {metadata.Success}."); if (!(metadataTable is CassandraMetadataTable)) { Assert.True(metadata.Id == 2, $"Migration metadata id should be: 2, but found {metadata.Id}."); } Assert.True(metadata.Type == MetadataType.Migration, $"Migration metadata type should be: Migration, but found {metadata.Type}."); Assert.True(metadata.InstalledOn.Date == DateTime.UtcNow.Date, $"Migration metadata InstalledOn date {metadata.InstalledOn.Date} should be equals to {DateTime.UtcNow.Date}."); return(metadataTable); }
public static IEvolveMetadata AssertRepeatableMigrationSave(this IEvolveMetadata metadataTable) { metadataTable.SaveMigration(FileMigrationScriptR, true); Assert.True(metadataTable.GetAllMigrationMetadata().Count() == 1, $"1 migration metadata should have been found, instead of {metadataTable.GetAllMigrationMetadata().Count()}."); Assert.True(metadataTable.GetAllRepeatableMigrationMetadata().Count() == 1, $"1 repeatable migration metadata should have been found, instead of {metadataTable.GetAllRepeatableMigrationMetadata().Count()}."); var metadata = metadataTable.GetAllRepeatableMigrationMetadata().First(); Assert.True(metadata.Version == FileMigrationScriptR.Version, $"Repeatable migration metadata version should be: null, but found {metadata.Version}."); Assert.True(metadata.Checksum == FileMigrationScriptR.CalculateChecksum(), $"Repeatable migration metadata checksum should be; 71568061B2970A4B7C5160FE75356E10, but found {metadata.Checksum}."); Assert.True(metadata.Description == FileMigrationScriptR.Description, $"Repeatable migration metadata description should be: desc b, but found {metadata.Description}."); Assert.True(metadata.Name == FileMigrationScriptR.Name, $"Repeatable migration metadata name should be: R__desc_b.sql, but found {metadata.Name}."); Assert.True(metadata.Success == true, $"Repeatable migration metadata success should be: true, but found {metadata.Success}."); if (!(metadataTable is CassandraMetadataTable)) { Assert.True(metadata.Id == 3, $"Repeatable migration metadata id should be: 3, but found {metadata.Id}."); } Assert.True(metadata.Type == MetadataType.RepeatableMigration, $"Repeatable migration metadata type should be: RepeatableMigration, but found {metadata.Type}."); Assert.True(metadata.InstalledOn.Date == DateTime.UtcNow.Date, $"Repeatable migration metadata InstalledOn date {metadata.InstalledOn.Date} should be equals to {DateTime.UtcNow.Date}."); return(metadataTable); }
public static bool IsEmptySchemaMetadataExists(this IEvolveMetadata metadata, string schemaName) => IsEvolveInitialized(metadata) && metadata.GetAllMetadata().Any(x => x.Type == MetadataType.EmptySchema && x.Name == schemaName);