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

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable <IDomainEventHandler <TestDomainEvent> > results = sut.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >();

            Assert.AreEqual(0, results.Count());
        }
        public void EmptyListIsReturnedIfNotHandlersRegistered()
        {
            var builder = new ContainerBuilder();
            IContainer container = builder.Build();

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable<IDomainEventHandler<TestDomainEvent>> results = sut.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>();

            Assert.AreEqual(0, results.Count());
        }
        public void SingleRegisteredEventHandlerIsReturned()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<TestDomainEventHandler>().As<IDomainEventHandler<TestDomainEvent>>();
            builder.RegisterType<SecondDomainEventHandler>().As<IDomainEventHandler<SecondTestDomainEvent>>();
            IContainer container = builder.Build();

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable<IDomainEventHandler<TestDomainEvent>> results = sut.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>();

            Assert.AreEqual(1, results.Count());
            Assert.IsInstanceOfType(results.Single(), typeof(TestDomainEventHandler));
        }
        public void SingleRegisteredEventHandlerIsReturned()
        {
            var builder = new ContainerBuilder();

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

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable <IDomainEventHandler <TestDomainEvent> > results = sut.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >();

            Assert.AreEqual(1, results.Count());
            Assert.IsInstanceOfType(results.Single(), typeof(TestDomainEventHandler));
        }
        public void MultipleRegisteredEventHandlersAreReturned()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<TestDomainEventHandler>().As<IDomainEventHandler<TestDomainEvent>>();
            builder.RegisterType<SecondDomainEventHandler>().As<IDomainEventHandler<SecondTestDomainEvent>>();
            builder.RegisterType<AnotherDomainEventHandler>().As<IDomainEventHandler<TestDomainEvent>>();
            IContainer container = builder.Build();

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable<IDomainEventHandler<TestDomainEvent>> results = sut.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>();

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

            Assert.IsNotNull(results.OfType<TestDomainEventHandler>().SingleOrDefault());
            Assert.IsNotNull(results.OfType<AnotherDomainEventHandler>().SingleOrDefault());
        }
        public void MultipleRegisteredEventHandlersAreReturned()
        {
            var builder = new ContainerBuilder();

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

            ContainerDomainEventHandlerResolver sut = new ContainerDomainEventHandlerResolver(container);
            IEnumerable <IDomainEventHandler <TestDomainEvent> > results = sut.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >();

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

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