public async Task EnsureSchemaInitialized()
        {
            // `receptionDelay` should include transaction timeout + clock drift. Otherwise, it may skip events during reception.
            var receptionDelay = TimeSpan.FromMilliseconds(3000);
            var eventStore     = Wireup.Init()
                                 .UsingSqlPersistence(ConnectionString)
                                 .WithDialect(new PostgreSqlDialect())
                                 .InitializeStorageEngine()
                                 .UsingJsonSerialization()
                                 .Build();

            eventStore.Advanced.Purge();
            _eventStore = eventStore;
            Outbox      = new NEventStoreOutbox(eventStore, receptionDelay);
            var db = new TestDbContextWithOutbox(ConnectionString, Outbox);

            db.Database.CreateIfNotExists();
            // Warm-up
            for (int i = 0; i < 2; i++)
            {
                using var warmUpDb = NewDbContext();
                warmUpDb.Users.Add(new UserAggregate(Guid.NewGuid(), ""));
                await warmUpDb.SaveChangesAsync();
            }
        }
        public async Task EnsureSchemaInitialized()
        {
            // `receptionDelay` should include transaction timeout + clock drift. Otherwise, it may skip events during reception.
            var receptionDelay = TimeSpan.FromMilliseconds(3000);
            var eventStore     = Wireup.Init()
                                 .UsingSqlPersistence(NpgsqlFactory.Instance, ConnectionString)
                                 .WithDialect(new PostgreSqlDialect())
                                 .UsingJsonSerialization()
                                 .Build();

            _eventStore = eventStore;
            Outbox      = new NEventStoreOutbox(eventStore, receptionDelay);
            var options = new DbContextOptionsBuilder().UseNpgsql(ConnectionString).Options;
            var db      = new TestDbContextWithOutbox(options, Outbox);

            try
            {
                _ = db.Users.FirstOrDefault();
            }
            catch (PostgresException)
            {
                await db.Database.EnsureDeletedAsync();

                await db.Database.EnsureCreatedAsync();
            }

            eventStore.Advanced.Initialize();
            eventStore.Advanced.Purge();
        }
Beispiel #3
0
        public void EnsureSchemaInitialized()
        {
            // `receptionDelay` should include transaction timeout + clock drift. Otherwise, it may skip events during reception.
            var receptionDelay = TimeSpan.FromMilliseconds(3000);
            var eventStore     = Wireup.Init()
                                 .UsingSqlPersistence(null, "System.Data.SqlClient", ConnectionString)
                                 .WithDialect(new MsSqlDialect())
                                 .InitializeStorageEngine()
                                 .UsingJsonSerialization()
                                 .Build();

            eventStore.Advanced.Purge();
            _eventStore = eventStore;
            Outbox      = new NEventStoreOutbox(eventStore, receptionDelay);
            var db = new TestDbContextWithOutbox(ConnectionString, Outbox);

            db.Database.CreateIfNotExists();
        }
        public async Task EnsureSchemaInitialized()
        {
            // `receptionDelay` should include transaction timeout + clock drift. Otherwise, it may skip events during reception.
            var receptionDelay = TimeSpan.FromMilliseconds(3000);
            var eventStore     = Wireup.Init()
                                 .UsingSqlPersistence(SQLiteFactory.Instance, "Data Source=EventSourcingDoorOutbox.db;journal mode=WAL;cache=private;")
                                 .WithDialect(new SqliteDialect())
                                 .UsingJsonSerialization()
                                 .Build();

            _eventStore = eventStore;
            Outbox      = new NEventStoreOutbox(eventStore, receptionDelay);
            using (var db = new TestDbContextWithOutbox(new SQLiteConnection(ConnectionString), Outbox))
            {
                db.Database.CreateIfNotExists();
            }

            eventStore.Advanced.Initialize();
            eventStore.Advanced.Purge();
        }