public void When_the_EventStoreDbContext_seeds_it_calls_the_specified_seed_action_if_it_has_been_set() { var numberOfEventsToSeed = Any.PositiveInt(100); var methodName = MethodBase.GetCurrentMethod().Name; eventStoreInitializer.OnSeed = ctx => { var aggregateId = Guid.NewGuid(); Enumerable.Range(20, numberOfEventsToSeed) .ForEach(i => ctx.Events.Add(new StorableEvent { AggregateId = aggregateId, SequenceNumber = i, Body = "test event!", StreamName = GetType().Name, Type = methodName })); }; using (var eventStore = new EventStoreDbContext()) { eventStoreInitializer.InitializeDatabase(eventStore); eventStore.Events.Count().Should().Be(numberOfEventsToSeed); } }
public void When_a_read_only_user_connects_to_the_event_store_Then_migrations_should_not_be_run() { var userName = Any.CamelCaseName(); var password = "******"; var loginName = userName; var user = new DbReadonlyUser(userName, loginName); var builder = new SqlConnectionStringBuilder(); var migrated = false; using (var db = new EventStoreDbContext()) { db.Database.ExecuteSqlCommand(string.Format("CREATE LOGIN [{0}] WITH PASSWORD = '******';", userName, password)); db.CreateReadonlyUser(user); builder.ConnectionString = db.Database.Connection.ConnectionString; builder.IntegratedSecurity = false; builder.UserID = user.LoginName; builder.Password = password; } using (var db = new EventStoreDbContext(builder.ConnectionString)) { IDbMigrator[] migrations = { new AnonymousMigrator(c => migrated = true, new Version(1, 0), Any.CamelCaseName()) }; var initializer = new EventStoreDatabaseInitializer <EventStoreDbContext>(migrations); initializer.InitializeDatabase(db); } migrated.Should().BeFalse(); }
public void When_the_EventStoreDbContext_seeds_it_calls_the_specified_seed_action_if_it_has_been_set() { var numberOfEventsToSeed = Any.PositiveInt(100); var methodName = MethodBase.GetCurrentMethod().Name; var eventStoreInitializer1 = new EventStoreDatabaseInitializer<EventStoreDbContext>(); eventStoreInitializer1.OnSeed = ctx => { var aggregateId = Guid.NewGuid(); Enumerable.Range(20, numberOfEventsToSeed) .ForEach(i => ctx.Events.Add(new StorableEvent { AggregateId = aggregateId, SequenceNumber = i, Body = "test event!", StreamName = GetType().Name, Type = methodName })); }; using (var eventStore = new EventStoreDbContext()) { eventStoreInitializer1.InitializeDatabase(eventStore); eventStore.Events.Count().Should().Be(numberOfEventsToSeed); } }
public void SeedFromFile_can_be_used_to_seed_the_event_store_from_config() { var eventStoreInitializer1 = new EventStoreDatabaseInitializer<EventStoreDbContext>(); eventStoreInitializer1.OnSeed = ctx => { var file = Settings.GetFile(f => f.Name == "Events.json"); ctx.SeedFromFile(file); }; using (var eventStore = new EventStoreDbContext()) { eventStoreInitializer1.InitializeDatabase(eventStore); eventStore.Events.Count().Should().Be(8); } }
public void SeedFromFile_can_be_used_to_seed_the_event_store_from_config() { var eventStoreInitializer1 = new EventStoreDatabaseInitializer <EventStoreDbContext>(); eventStoreInitializer1.OnSeed = ctx => { var file = Settings.GetFile(f => f.Name == "Events.json"); ctx.SeedFromFile(file); }; using (var eventStore = new EventStoreDbContext()) { eventStoreInitializer1.InitializeDatabase(eventStore); eventStore.Events.Count().Should().Be(8); } }