Exemplo n.º 1
0
        public void Setup()
        {
            unitOfWorkDomainEventHandler1 = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            unitOfWorkDomainEventHandler2 = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();

            unitOfWorkDomainEventHandlers = new List <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >
            {
                unitOfWorkDomainEventHandler1,
                unitOfWorkDomainEventHandler2
            };

            domainEventHandler3 = Substitute.For <IDomainEventHandler <TestDomainEvent> >();
            domainEventHandler4 = Substitute.For <IDomainEventHandler <TestDomainEvent> >();
            domainEventHandlers = new List <IDomainEventHandler <TestDomainEvent> >
            {
                domainEventHandler3,
                domainEventHandler4
            };

            eventHandlerResolver           = Substitute.For <IDomainEventHandlerResolver>();
            unitOfWorkEventHandlerResolver = Substitute.For <IUnitOfWorkDomainEventHandlerResolver>();
            unitOfWork = Substitute.For <TestUnitOfWork>();

            domainEvent = new TestDomainEvent(Guid.NewGuid());
            unitOfWorkEventHandlerResolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(unitOfWorkDomainEventHandlers);
            eventHandlerResolver.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >().Returns(domainEventHandlers);

            sut = new TestUnitOfWorkDomainRepository(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork);
        }
        public void Setup()
        {
            unitOfWorkDomainEventHandler1 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            unitOfWorkDomainEventHandler2 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            
            unitOfWorkDomainEventHandlers = new List<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>
            {
                unitOfWorkDomainEventHandler1,
                unitOfWorkDomainEventHandler2
            };

            domainEventHandler3 = Substitute.For<IDomainEventHandler<TestDomainEvent>>();
            domainEventHandler4 = Substitute.For<IDomainEventHandler<TestDomainEvent>>();
            domainEventHandlers = new List<IDomainEventHandler<TestDomainEvent>>
            {
                domainEventHandler3,
                domainEventHandler4
            };

            eventHandlerResolver = Substitute.For<IDomainEventHandlerResolver>();
            unitOfWorkEventHandlerResolver = Substitute.For<IUnitOfWorkDomainEventHandlerResolver>();
            unitOfWork = Substitute.For<TestUnitOfWork>();

            domainEvent = new TestDomainEvent(Guid.NewGuid());
            unitOfWorkEventHandlerResolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(unitOfWorkDomainEventHandlers);
            eventHandlerResolver.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>().Returns(domainEventHandlers);

            sut = new TestUnitOfWorkDomainRepository(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UnitOfWorkDomainRepository{TUnitOfWork, TAggregate}"/> class.
        /// </summary>
        /// <param name="eventHandlerResolver">Event handler resolver for finding domain event handlers.</param>
        /// <param name="unitOfWorkEventHandlerResolver">Event handler resolver for finding unit-of-work domain event handlers.</param>
        /// <param name="unitOfWork">The Unit of Work context instance.</param>
        protected UnitOfWorkDomainRepository(IDomainEventHandlerResolver eventHandlerResolver,
                                             IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, TUnitOfWork unitOfWork)
            : base(new UnitOfWorkDomainEventBroker <TUnitOfWork>(unitOfWorkEventHandlerResolver, unitOfWork))
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            this.unitOfWork      = unitOfWork;
            immediateEventBroker = new DomainEventBroker(eventHandlerResolver);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnitOfWorkDomainEventBroker{TUnitOfWork}"/> class.
        /// </summary>
        /// <param name="eventHandlerResolver">Event handler resolver instance for finding domain event handlers.</param>
        /// <param name="unitOfWork">The Unit of Work context instance.</param>
        public UnitOfWorkDomainEventBroker(IUnitOfWorkDomainEventHandlerResolver eventHandlerResolver, TUnitOfWork unitOfWork)
        {
            if (eventHandlerResolver == null)
            {
                throw new ArgumentNullException("eventHandlerResolver");
            }
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            this.eventHandlerResolver = eventHandlerResolver;
            this.unitOfWork           = unitOfWork;
        }
        public void Setup()
        {
            unitOfWork               = new TestUnitOfWork();
            domainEventHandler1      = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            domainEventHandler2      = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            domainEventHandler3      = Substitute.For <IUnitOfWorkDomainEventHandler <AnotherTestDomainEvent, TestUnitOfWork> >();
            asyncDomainEventHandler1 = Substitute.For <IAsyncUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            asyncDomainEventHandler2 = Substitute.For <IAsyncUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            asyncDomainEventHandler3 = Substitute.For <IAsyncUnitOfWorkDomainEventHandler <AnotherTestDomainEvent, TestUnitOfWork> >();

            resolver = Substitute.For <IUnitOfWorkDomainEventHandlerResolver>();
            resolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(new[] { domainEventHandler1, domainEventHandler2 });
            resolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(new[] { domainEventHandler1, domainEventHandler2 });
            resolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <AnotherTestDomainEvent, TestUnitOfWork> >().Returns(new[] { domainEventHandler3 });
            resolver.ResolveEventHandlers <IAsyncUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 });
            resolver.ResolveEventHandlers <IAsyncUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 });
            resolver.ResolveEventHandlers <IAsyncUnitOfWorkDomainEventHandler <AnotherTestDomainEvent, TestUnitOfWork> >().Returns(new[] { asyncDomainEventHandler3 });

            sut = new UnitOfWorkDomainEventBroker <TestUnitOfWork>(resolver, unitOfWork);
        }
        public void Setup()
        {
            unitOfWork = new TestUnitOfWork();
            domainEventHandler1 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            domainEventHandler2 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            domainEventHandler3 = Substitute.For<IUnitOfWorkDomainEventHandler<AnotherTestDomainEvent, TestUnitOfWork>>();
            asyncDomainEventHandler1 = Substitute.For<IAsyncUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            asyncDomainEventHandler2 = Substitute.For<IAsyncUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>();
            asyncDomainEventHandler3 = Substitute.For<IAsyncUnitOfWorkDomainEventHandler<AnotherTestDomainEvent, TestUnitOfWork>>();

            resolver = Substitute.For<IUnitOfWorkDomainEventHandlerResolver>();
            resolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(new[] { domainEventHandler1, domainEventHandler2 });
            resolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(new[] { domainEventHandler1, domainEventHandler2 });
            resolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<AnotherTestDomainEvent, TestUnitOfWork>>().Returns(new[] { domainEventHandler3 });
            resolver.ResolveEventHandlers<IAsyncUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 });
            resolver.ResolveEventHandlers<IAsyncUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 });
            resolver.ResolveEventHandlers<IAsyncUnitOfWorkDomainEventHandler<AnotherTestDomainEvent, TestUnitOfWork>>().Returns(new[] { asyncDomainEventHandler3 });

            sut = new UnitOfWorkDomainEventBroker<TestUnitOfWork>(resolver, unitOfWork);
        }
 public TestUnitOfWorkDomainRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, TestUnitOfWork unitOfWork)
     : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork)
 {
 }
Exemplo n.º 8
0
 public InternalCompositeRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, InternalUnitOfWork unitOfWork)
     : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork)
 {
 }
Exemplo n.º 9
0
 public AuditTrailEntryDomainRepository(IDomainEventHandlerResolver eventHandlerResolver,
                                        IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, IDbContext unitOfWork)
     : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork)
 {
 }