protected override void Given() { var eventBus = new InMemoryEventBus(new MessageRouterStub()); var eventStore = new StubEventStore(eventBus); var events = new List<IDomainEvent>(); events.Add(new ValidEvent(Guid.Empty) { EventNumber = 0 }); events.Add(new AnotherValidEvent(Guid.Empty) { EventNumber = 1 }); events.Add(new ValidEvent(Guid.Empty) { EventNumber = 2 }); events.Add(new AnotherValidEvent(Guid.Empty) { EventNumber = 3 }); eventStore.InsertEvents(events); _aggregate = eventStore.Get<StubAggregate>(Guid.Empty); }
protected override void Given() { _stubEventBus = new InMemoryEventBus(new MessageRouterStub()); _publishedEvents = new List<IDomainEvent>(); _stubEventBus.EventPublished = (y) => _publishedEvents.Add(y); _eventStore = new StubEventStore(_stubEventBus); _aggregate = new StubAggregate(); _aggregate.DoThis(); _aggregate.DoSomethingElse(); _aggregate.DoThis(); _aggregate.DoSomethingElse(); _eventStore.Insert(_aggregate); _eventStore.Commit(); }
protected override void Given() { var stubUnitOfWork = new InMemoryEventBus(new MessageRouterStub()); var eventStore = new StubEventStore(stubUnitOfWork); _aggregate = eventStore.Get<StubAggregate>(Guid.Empty); }
public void All_The_Events_Should_Be_Returned_In_The_Right_Order() { var eventBus = new InMemoryEventBus(new MessageRouterStub()); var eventStore = new StubEventStore(eventBus); var events = new List<IDomainEvent>(); events.Add(new ValidEvent(Guid.Empty) { EventNumber = 0 }); events.Add(new AnotherValidEvent(Guid.Empty) { EventNumber = 1 }); events.Add(new ValidEvent(Guid.Empty) { EventNumber = 2 }); events.Add(new AnotherValidEvent(Guid.Empty) { EventNumber = 3 }); eventStore.InsertEvents(events); var retrievedEvents = eventStore.GetAllEvents(); Assert.AreEqual(4, retrievedEvents.Count()); for(var count = 0; count < 4; count++) { var @event = retrievedEvents.ElementAt(count); Assert.AreEqual(count, @event.EventNumber); if(count % 2== 0) Assert.IsInstanceOf<ValidEvent>(@event); else { Assert.IsInstanceOf<AnotherValidEvent>(@event); } } }