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");
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }