Affecto.Patterns.Domain.UnitOfWork.Tests.UnitOfWorkDomainRepositoryTests.OnlyUnitOfWorkEventsAreHandledIfCommitFails C# (CSharp) Метод

OnlyUnitOfWorkEventsAreHandledIfCommitFails() приватный Метод

private OnlyUnitOfWorkEventsAreHandledIfCommitFails ( ) : void
Результат void
        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);
        }
    }