public void InaccessibleTypeParameterCanBeUsed()
        {
            // This test is necessary for checking that the repository can be used with inaccessible type parameters.
            // See the bug in .NET Framework: https://connect.microsoft.com/VisualStudio/feedback/details/672411/bug-in-dynamic-dispatch-when-using-generic-type-parameters

            InternalAggregateRoot aggregateRoot = new InternalAggregateRoot(Guid.NewGuid());
            aggregateRoot.ApplyEvent(domainEvent);

            var privateSut = new InternalAsyncDomainRepository(eventHandlerResolver);
            privateSut.ApplyChangesAsync(aggregateRoot).Wait();

            domainEventHandler1.Received().ExecuteAsync(domainEvent);
            domainEventHandler2.Received().ExecuteAsync(domainEvent);
        }
        public void InaccessibleTypeParameterCanBeUsed()
        {
            // This test is necessary for checking that the repository can be used with inaccessible type parameters.
            // See the bug in .NET Framework: https://connect.microsoft.com/VisualStudio/feedback/details/672411/bug-in-dynamic-dispatch-when-using-generic-type-parameters

            InternalAggregateRoot aggregateRoot = new InternalAggregateRoot(Guid.NewGuid());

            aggregateRoot.ApplyEvent(domainEvent);

            var privateSut = new InternalDomainRepository(eventHandlerResolver);

            privateSut.ApplyChanges(aggregateRoot);

            domainEventHandler1.Received().Execute(domainEvent);
            domainEventHandler2.Received().Execute(domainEvent);
        }
        public void InaccessibleTypeParametersCanBeUsed()
        {
            // This test is necessary for checking that the repository can be used with inaccessible type parameters.
            // See the bug in .NET Framework: https://connect.microsoft.com/VisualStudio/feedback/details/672411/bug-in-dynamic-dispatch-when-using-generic-type-parameters

            IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> domainEventHandler =
                Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> >();
            IEnumerable <IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> > eventHandlers = new List
                                                                                                               <IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> >
            {
                domainEventHandler
            };

            unitOfWorkEventHandlerResolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> >().Returns(eventHandlers);
            unitOfWorkEventHandlerResolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, InternalUnitOfWork> >().Returns(eventHandlers);

            InternalAggregateRoot aggregateRoot = new InternalAggregateRoot(Guid.NewGuid());

            aggregateRoot.ApplyEvent(domainEvent1);

            TestAggregateRoot2 aggregateRoot2 = new TestAggregateRoot2(Guid.NewGuid());

            aggregateRoot.ApplyEvent(domainEvent2);

            InternalUnitOfWork internalUnitOfWork = new InternalUnitOfWork();

            var privateSut = new InternalCompositeRepository(eventHandlerResolver, unitOfWorkEventHandlerResolver, internalUnitOfWork);

            privateSut.ApplyChanges(aggregateRoot, aggregateRoot2);

            Received.InOrder(() =>
            {
                domainEventHandler.Execute(domainEvent1, internalUnitOfWork);
                domainEventHandler.Execute(domainEvent2, internalUnitOfWork);
                internalUnitOfWork.SaveChanges();
            });
        }