public void UpsertStructureSet_WhenCalledTwice_UpserterIsCalledOnceNotTwice() { var settings = new Mock <IDbSettings>(); settings.SetupGet(f => f.AllowDynamicSchemaCreation).Returns(true); settings.SetupGet(f => f.AllowDynamicSchemaUpdates).Returns(true); var dbFake = new Mock <ISisoDatabase>(); dbFake.SetupGet(f => f.Settings).Returns(settings.Object); var upserterFake = new Mock <IDbSchemaUpserter>(); var dbClientFake = CreateDbClientFake(); var manager = new DbSchemas(dbFake.Object, upserterFake.Object); manager.Upsert(_structureSchema, dbClientFake.Object); manager.Upsert(_structureSchema, dbClientFake.Object); upserterFake.Verify(f => f.Upsert(_structureSchema, dbClientFake.Object, true, true), Times.Once()); }
protected virtual void OnUpsertStructureSets(Type[] types) { if (!Settings.AllowsAnyDynamicSchemaChanges()) { return; } using (var dbClient = ProviderFactory.GetTransactionalDbClient(_connectionInfo)) { foreach (var type in types) { CacheProvider.ClearByType(type); var structureSchema = StructureSchemas.GetSchema(type); DbSchemas.Upsert(structureSchema, dbClient); } } }
public void UpsertStructureSet_WhenDbSettingsDoesNotAllowAnyChanges_UpserterIsNeverCalled() { var settings = new Mock <IDbSettings>(); settings.SetupGet(f => f.AllowDynamicSchemaCreation).Returns(false); settings.SetupGet(f => f.AllowDynamicSchemaUpdates).Returns(false); var dbFake = new Mock <ISisoDatabase>(); dbFake.SetupGet(f => f.Settings).Returns(settings.Object); var upserterFake = new Mock <IDbSchemaUpserter>(); var dbClientFake = CreateDbClientFake(); var manager = new DbSchemas(dbFake.Object, upserterFake.Object); manager.Upsert(_structureSchema, dbClientFake.Object); upserterFake.Verify(f => f.Upsert(_structureSchema, dbClientFake.Object, false, false), Times.Never()); }