public void WhenIScheduleAMeeting() { var scheduleMeetingCommand = new ScheduleMeetingCommand(MEETING_ID, meetingDate, locationId, speakerId, capacity); new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", DATA_BASE_FILE); var domainEventStorage = new DomainEventStorage <IDomainEvent>(sqliteConnectionString, new BinaryFormatter()); var eventStoreIdentityMap = new EventStoreIdentityMap <IDomainEvent>(); var bus = new DirectBus(new MessageRouter()); var eventStoreUnitOfWork = new EventStoreUnitOfWork <IDomainEvent>(domainEventStorage, eventStoreIdentityMap, bus); var repository = new DomainRepository <IDomainEvent>(eventStoreUnitOfWork, eventStoreIdentityMap); new ReportingDatabaseBootStrapper().ReCreateDatabaseSchema(); reportingRepository = new SQLiteReportingRepository(sqliteConnectionString, new SqlSelectBuilder(), new SqlInsertBuilder(), new SqlUpdateBuilder(), new SqlDeleteBuilder()); handler = new ScheduleMeetingCommandHandler(repository); var messageRouter = new MessageRouter(); messageRouter.Register <ScheduleMeetingCommand>(command => handler.Handle(command)); bus.Publish(scheduleMeetingCommand); //how do we publish to report, directly or via command handler. Looks like by using transaction handler we go through unit of work whose commit method fires events to BUS //so if we have event and then save they get re-ublished and report canpick up }
public void WhenIScheduleAMeeting() { var scheduleMeetingCommand = new ScheduleMeetingCommand(MEETING_ID, meetingDate, locationId, speakerId, capacity); new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", DATA_BASE_FILE); var domainEventStorage = new DomainEventStorage<IDomainEvent>(sqliteConnectionString, new BinaryFormatter()); var eventStoreIdentityMap = new EventStoreIdentityMap<IDomainEvent>(); var bus = new DirectBus(new MessageRouter()); var eventStoreUnitOfWork = new EventStoreUnitOfWork<IDomainEvent>(domainEventStorage, eventStoreIdentityMap, bus); var repository = new DomainRepository<IDomainEvent>(eventStoreUnitOfWork, eventStoreIdentityMap); new ReportingDatabaseBootStrapper().ReCreateDatabaseSchema(); reportingRepository = new SQLiteReportingRepository(sqliteConnectionString, new SqlSelectBuilder(), new SqlInsertBuilder(), new SqlUpdateBuilder(), new SqlDeleteBuilder()); handler = new ScheduleMeetingCommandHandler(repository); var messageRouter = new MessageRouter(); messageRouter.Register<ScheduleMeetingCommand>(command => handler.Handle(command)); bus.Publish(scheduleMeetingCommand); //how do we publish to report, directly or via command handler. Looks like by using transaction handler we go through unit of work whose commit method fires events to BUS //so if we have event and then save they get re-ublished and report canpick up }
public void SetUp() { new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", dataBaseFile); _domainEventStorage = new DomainEventStorage(sqliteConnectionString, new BinaryFormatter()); _eventStoreIdentityMap = new EventStoreIdentityMap(); _eventStoreUnitOfWork = new EventStoreUnitOfWork(_domainEventStorage, _eventStoreIdentityMap, new Mock<IBus>().Object); _repository = new DomainRepository(_eventStoreUnitOfWork, _eventStoreIdentityMap); }
public void SetUp() { new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", dataBaseFile); _domainEventStorage = new DomainEventStorage <IDomainEvent>(sqliteConnectionString, new BinaryFormatter()); _eventStoreIdentityMap = new EventStoreIdentityMap <IDomainEvent>(); _eventStoreUnitOfWork = new EventStoreUnitOfWork <IDomainEvent>(_domainEventStorage, _eventStoreIdentityMap, new Mock <IBus>().Object); _repository = new DomainRepository <IDomainEvent>(_eventStoreUnitOfWork, _eventStoreIdentityMap); }
protected override void Context() { new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", DATA_BASE_FILE); var domainEventStorage = new DomainEventStorage<IDomainEvent>(sqliteConnectionString, new BinaryFormatter()); var eventStoreIdentityMap = new EventStoreIdentityMap<IDomainEvent>(); var eventStoreUnitOfWork = new EventStoreUnitOfWork<IDomainEvent>(domainEventStorage, eventStoreIdentityMap, MockRepository.GenerateStub<IBus>()); repository = new DomainRepository<IDomainEvent>(eventStoreUnitOfWork, eventStoreIdentityMap); scheduleMeetingCommand = new ScheduleMeetingCommand(meetingId, meetingTime, locationId, speakerId, CAPACITY); scheduleMeetingCommandHandler = new ScheduleMeetingCommandHandler(repository); }
protected override void Context() { new DomainDatabaseBootStrapper().ReCreateDatabaseSchema(); var sqliteConnectionString = string.Format("Data Source={0}", DATA_BASE_FILE); var domainEventStorage = new DomainEventStorage <IDomainEvent>(sqliteConnectionString, new BinaryFormatter()); var eventStoreIdentityMap = new EventStoreIdentityMap <IDomainEvent>(); var eventStoreUnitOfWork = new EventStoreUnitOfWork <IDomainEvent>(domainEventStorage, eventStoreIdentityMap, MockRepository.GenerateStub <IBus>()); repository = new DomainRepository <IDomainEvent>(eventStoreUnitOfWork, eventStoreIdentityMap); scheduleMeetingCommand = new ScheduleMeetingCommand(meetingId, meetingTime, locationId, speakerId, CAPACITY); scheduleMeetingCommandHandler = new ScheduleMeetingCommandHandler(repository); }
public static void EventsSavedForAggregate <TAggregate>(Guid aggregateId, params Event[] expectedEvents) where TAggregate : Aggregate { IEnumerable <Event> actualEvents = new Event[] {}; EventStoreUnitOfWork unitOfWork = DIExtensions.Container.GetInstance <EventStoreUnitOfWork>(); unitOfWork.DoInTransaction(() => { IEventRepository eventRepository = unitOfWork.EventRepository; actualEvents = eventRepository.GetEventsForAggregate <TAggregate>(aggregateId); }); foreach (Event @event in actualEvents) { @event.ProcessId = Guid.Empty; } Assert.That(actualEvents, Is.EquivalentTo(expectedEvents)); }
public void SetUp() { var connectionString = ConnectionStringProvider.ConnectionString; _sqlExecutor = new SqlExecutor(); _sqlExecutor.ExecuteNonQuery($"DELETE FROM dbo.Events WHERE ID IN ('{Id1}','{Id2}')"); _sqlExecutor.ExecuteNonQuery($"DELETE FROM dbo.EventsToPublish WHERE ID IN ('{Id1}','{Id2}')"); var eventStoreUnitOfWork = new EventStoreUnitOfWork(connectionString); _eventToPublishRepositoryDecorator = CreateEventToPublishRepositoryThatCanSimulateSqlExceptions( new EventToPublishRepository(new EventToPublishSerializer(Assembly.GetExecutingAssembly()) ) ); _eventToPublishRepositoryDecorator.UnitOfWork = eventStoreUnitOfWork; _eventStore = new EventRepository(new EventSerializer(Assembly.GetExecutingAssembly())) { UnitOfWork = eventStoreUnitOfWork }; _eventHandler = new EventHandler( new CompositeEventStore( new[] { _eventStore, _eventToPublishRepositoryDecorator } ) ); _testEvent = new TestEvent { Id = new Guid(Id1), AggregateId = _aggregateId }; _testEvent2 = new TestEvent2 { Id = new Guid(Id2), AggregateId = _aggregateId }; }
public OpenLibraryModule(EventStoreUnitOfWork unitOfWork, ICommandHandler <OpenLibrary> commandHandler, NHibernateUnitOfWork relationalUnitOfWork, EventDispatcher eventDispatcher) : base(unitOfWork, commandHandler, "/libraries/", relationalUnitOfWork, eventDispatcher) { }
public RemoveBookModule(EventStoreUnitOfWork unitOfWork, ICommandHandler <RemoveBookFromLibrary> commandHandler, NHibernateUnitOfWork relationalUnitOfWork, EventDispatcher eventDispatcher) : base(unitOfWork, commandHandler, "/libraries/{AggregateId}/books/remove", relationalUnitOfWork, eventDispatcher) { }
public AddBookModule(EventStoreUnitOfWork unitOfWork, ICommandHandler <AddBookToLibrary> commandHandler, NHibernateUnitOfWork relationalUnitOfWork, EventDispatcher eventDispatcher) : base(unitOfWork, commandHandler, "/libraries/{AggregateId}/books/add", relationalUnitOfWork, eventDispatcher) { }
public AcceptLinkModule(EventStoreUnitOfWork unitOfWork, ICommandHandler <AcceptLink> commandHandler, NHibernateUnitOfWork relationalUnitOfWork, EventDispatcher eventDispatcher) : base(unitOfWork, commandHandler, "/libraries/{AggregateId}/links/accept/", relationalUnitOfWork, eventDispatcher) { }