Exemplo n.º 1
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));
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
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());
        }