Beispiel #1
0
        public void EmptyListIsReturnedIfNotHandlersRegistered()
        {
            var        builder   = new ContainerBuilder();
            IContainer container = builder.Build();

            ContainerUnitOfWorkDomainEventHandlerResolver sut = new ContainerUnitOfWorkDomainEventHandlerResolver(container);
            IEnumerable <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> > results = sut.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();

            Assert.AreEqual(0, results.Count());
        }
Beispiel #2
0
        public void SingleRegisteredEventHandlerIsReturned()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <TestDomainEventHandler>().As <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            builder.RegisterType <SecondDomainEventHandler>().As <IUnitOfWorkDomainEventHandler <SecondTestDomainEvent, TestUnitOfWork> >();
            IContainer container = builder.Build();

            ContainerUnitOfWorkDomainEventHandlerResolver sut = new ContainerUnitOfWorkDomainEventHandlerResolver(container);
            IEnumerable <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> > results = sut.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();

            Assert.AreEqual(1, results.Count());
            Assert.IsInstanceOfType(results.Single(), typeof(TestDomainEventHandler));
        }
Beispiel #3
0
        public void MultipleRegisteredEventHandlersAreReturned()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <TestDomainEventHandler>().As <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            builder.RegisterType <SecondDomainEventHandler>().As <IUnitOfWorkDomainEventHandler <SecondTestDomainEvent, TestUnitOfWork> >();
            builder.RegisterType <AnotherDomainEventHandler>().As <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();
            IContainer container = builder.Build();

            ContainerUnitOfWorkDomainEventHandlerResolver sut = new ContainerUnitOfWorkDomainEventHandlerResolver(container);
            IEnumerable <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> > results = sut.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >();

            Assert.AreEqual(2, results.Count());

            Assert.IsNotNull(results.OfType <TestDomainEventHandler>().SingleOrDefault());
            Assert.IsNotNull(results.OfType <AnotherDomainEventHandler>().SingleOrDefault());
        }