public void cannot_raise_uncorrelated_events() { var agg = new CorrelatedAggregate(); Assert.Throws <InvalidOperationException>(() => agg.RaiseUncorrelatedEvent()); agg.ApplyNewSource(_command); Assert.Throws <InvalidOperationException>(() => agg.RaiseUncorrelatedEvent()); Assert.Empty(agg.TakeEvents()); }
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()); }