public void OnlyUnitOfWorkEventsAreHandledIfCommitFails()
{
TestAggregateRoot aggregateRoot = new TestAggregateRoot(Guid.NewGuid());
aggregateRoot.ApplyEvent(domainEvent);
unitOfWork
.When(u => u.SaveChanges())
.Do(callInfo => { throw new InvalidOperationException(); });
try
{
sut.ApplyChanges(aggregateRoot);
Assert.Fail("No exception thrown.");
}
catch (InvalidOperationException)
{
}
unitOfWorkDomainEventHandler1.Received().Execute(domainEvent, unitOfWork);
unitOfWorkDomainEventHandler2.Received().Execute(domainEvent, unitOfWork);
unitOfWork.Received().SaveChanges();
domainEventHandler3.DidNotReceive().Execute(domainEvent);
domainEventHandler4.DidNotReceive().Execute(domainEvent);
}
}