예제 #1
0
        public void cannot_raise_externally_correlated_events()
        {
            var otherRoot = CorrelatedMessage.NewRoot();
            var agg       = new CorrelatedAggregate();

            Assert.Throws <InvalidOperationException>(() => agg.RaiseExternallyCorrelatedEvent(otherRoot));
            Assert.Throws <InvalidOperationException>(() => agg.RaiseExternallyCorrelatedEvent(otherRoot.CorrelationId, new SourceId(otherRoot)));
            agg.ApplyNewSource(_command);
            Assert.Throws <InvalidOperationException>(() => agg.RaiseExternallyCorrelatedEvent(otherRoot));
            Assert.Throws <InvalidOperationException>(() => agg.RaiseExternallyCorrelatedEvent(otherRoot.CorrelationId, new SourceId(otherRoot)));
            Assert.Empty(agg.TakeEvents());
        }
예제 #2
0
        public void cannot_raise_events_without_source()
        {
            var otherRoot = CorrelatedMessage.NewRoot();
            var agg       = new CorrelatedAggregate();

            Assert.Throws <NullReferenceException>(() => agg.RaiseCorrelatedEvent());
            Assert.Throws <InvalidOperationException>(() => agg.RaiseUncorrelatedEvent());
            Assert.Throws <InvalidOperationException>(() => agg.RaiseExternallyCorrelatedEvent(otherRoot));
            agg.ApplyNewSource(otherRoot);
            agg.RaiseCorrelatedEvent();
            var evt = agg.TakeEvents()[0] as CorrelatedAggregate.CorrelatedEvent;

            Assert.NotNull(evt);
            Assert.Throws <NullReferenceException>(() => agg.RaiseCorrelatedEvent());
            Assert.Empty(agg.TakeEvents());
        }