public void GetSqlScripts() { // Act var sqlScripts = EventFlowEventStoresPostgreSql.GetSqlScripts().ToDictionary(s => s.Name, s => s); // Assert sqlScripts.Should().HaveCount(2); sqlScripts.Should().ContainKey("EventStores.Scripts.0001 - Create table EventFlow.sql"); sqlScripts.Should().ContainKey("EventStores.Scripts.0002 - Create eventdatamodel_list_type.sql"); }
public void SqlScriptsAreIdempotent() { // Arrange var sqlScripts = EventFlowEventStoresPostgreSql.GetSqlScripts().ToList(); // Act foreach (var _ in Enumerable.Range(0, 2)) { foreach (var sqlScript in sqlScripts) { _postgreSqlDatabase.Execute(sqlScript.Content); } } }
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) { _testDatabase = PostgreSqlHelpz.CreateDatabase("eventflow"); var resolver = eventFlowOptions .ConfigurePostgreSql(PostgreSqlConfiguration.New.SetConnectionString(_testDatabase.ConnectionString.Value)) .UseEventStore <PostgreSqlEventPersistence>() .CreateResolver(); var databaseMigrator = resolver.Resolve <IPostgreSqlDatabaseMigrator>(); EventFlowEventStoresPostgreSql.MigrateDatabase(databaseMigrator); databaseMigrator.MigrateDatabaseUsingEmbeddedScripts(GetType().Assembly); return(resolver); }
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) { _testDatabase = PostgreSqlHelpz.CreateDatabase("eventflow"); var resolver = eventFlowOptions .RegisterServices(sr => sr.RegisterType(typeof(ThingyMessageLocator))) .ConfigurePostgreSql(PostgreSqlConfiguration.New.SetConnectionString(_testDatabase.ConnectionString.Value)) .UsePostgreSqlReadModel <PostgreSqlThingyReadModel>() .UsePostgreSqlReadModel <PostgreSqlThingyMessageReadModel, ThingyMessageLocator>() .AddQueryHandlers( typeof(PostgreSqlThingyGetQueryHandler), typeof(PostgreSqlThingyGetVersionQueryHandler), typeof(PostgreSqlThingyGetMessagesQueryHandler)) .CreateResolver(); var databaseMigrator = resolver.Resolve <IPostgreSqlDatabaseMigrator>(); EventFlowEventStoresPostgreSql.MigrateDatabase(databaseMigrator); databaseMigrator.MigrateDatabaseUsingEmbeddedScripts(GetType().Assembly); return(resolver); }