public void UncommittedEventsShouldBeCommited() { var repository = CreateDomainRepository(); var aggregateRoot = new MyTestAggregateRoot(); aggregateRoot.Apply(new MyTestEvent()); aggregateRoot.Apply(new MyTestEvent()); repository.Save(aggregateRoot); Assert.AreEqual(0, aggregateRoot.UncommittedEvents.Count); }
public void UncommittedEventsArePublishedToTheEventBusWhenSaved() { var repository = CreateDomainRepository(); var aggregateRoot = new MyTestAggregateRoot(); var domainEvents = new List<DomainEvent> {new MyTestEvent(), new MyTestEvent(), new MyTestEvent()}; aggregateRoot.Apply(domainEvents[0]); aggregateRoot.Apply(domainEvents[1]); aggregateRoot.Apply(domainEvents[2]); repository.Save(aggregateRoot); mocker.GetMock<IEventBus>() .Verify(eventBus => eventBus.PublishEvents(It.IsAny<IEnumerable<DomainEvent>>()), Times.Once()); }
public void UncommittedEventsAreInsertedIntoTheEventStoreWhenSaved() { var repository = CreateDomainRepository(); var aggregateRoot = new MyTestAggregateRoot(); var domainEvents = new List<DomainEvent> {new MyTestEvent(), new MyTestEvent(), new MyTestEvent()}; aggregateRoot.Apply(domainEvents[0]); aggregateRoot.Apply(domainEvents[1]); aggregateRoot.Apply(domainEvents[2]); repository.Save(aggregateRoot); mocker.GetMock<IEventStore>() .Verify(eventStore => eventStore.Insert(It.Is<IEnumerable<DomainEvent>>(events => events.All(domainEvents.Contains))), Times.Once()); }
public void UncommittedEventsArePublishedToTheEventBusWhenSaved() { var repository = CreateDomainRepository(); var aggregateRoot = new MyTestAggregateRoot(); var domainEvents = new List <DomainEvent> { new MyTestEvent(), new MyTestEvent(), new MyTestEvent() }; aggregateRoot.Apply(domainEvents[0]); aggregateRoot.Apply(domainEvents[1]); aggregateRoot.Apply(domainEvents[2]); repository.Save(aggregateRoot); mocker.GetMock <IEventBus>() .Verify(eventBus => eventBus.PublishEvents(It.IsAny <IEnumerable <DomainEvent> >()), Times.Once()); }
public void UncommittedEventsAreInsertedIntoTheEventStoreWhenSaved() { var repository = CreateDomainRepository(); var aggregateRoot = new MyTestAggregateRoot(); var domainEvents = new List <DomainEvent> { new MyTestEvent(), new MyTestEvent(), new MyTestEvent() }; aggregateRoot.Apply(domainEvents[0]); aggregateRoot.Apply(domainEvents[1]); aggregateRoot.Apply(domainEvents[2]); repository.Save(aggregateRoot); mocker.GetMock <IEventStore>() .Verify(eventStore => eventStore.Insert(It.Is <IEnumerable <DomainEvent> >(events => events.All(domainEvents.Contains))), Times.Once()); }