コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }