Esempio n. 1
0
        public void DependencyResolverDiscoversCommandPublishers()
        {
            var mockConfigurationFactory = new Mock <IConfigurationFactory>();
            var notifyFailureConfig      = new NotifyOfFatalFailureServiceBusQueueCommandPublisherConfiguration {
                QueueName = "Three"
            };


            mockConfigurationFactory
            .Setup(factory => factory.Create(It.IsAny <Type>()))
            .Returns <Type>(type =>
            {
                if (type == typeof(NotifyOfFatalFailureServiceBusQueueCommandPublisherConfiguration))
                {
                    return(notifyFailureConfig);
                }

                return(Activator.CreateInstance(type));
            });

            var container = EntryPoint.CreateDependencyResolver(() => mockConfigurationFactory.Object);

            using (var scope = container.BeginLifetimeScope())
            {
                var processOrderPublisher = scope.Resolve <ICommandPublisher <NotifyOfFatalFailure> >();
                processOrderPublisher.Should().NotBeNull("because the NotifiyOfFatalFalure publisher should be resolvable");
            }
        }
Esempio n. 2
0
        public void DependencyResolverDiscoversWebJobFunctions()
        {
            var mockConfigurationFactory = new Mock <IConfigurationFactory>();
            var processOrderConfig       = new ProcessOrderServiceBusQueueCommandPublisherConfiguration {
                QueueName = "One"
            };
            var submitOrderConfig = new SubmitOrderForProductionServiceBusQueueCommandPublisherConfiguration {
                QueueName = "Two"
            };
            var notifyFailureConfig = new NotifyOfFatalFailureServiceBusQueueCommandPublisherConfiguration {
                QueueName = "Three"
            };

            mockConfigurationFactory
            .Setup(factory => factory.Create(It.IsAny <Type>()))
            .Returns <Type>(type =>
            {
                if (type == typeof(ProcessOrderServiceBusQueueCommandPublisherConfiguration))
                {
                    return(processOrderConfig);
                }
                else if (type == typeof(SubmitOrderForProductionServiceBusQueueCommandPublisherConfiguration))
                {
                    return(submitOrderConfig);
                }
                else if (type == typeof(NotifyOfFatalFailureServiceBusQueueCommandPublisherConfiguration))
                {
                    return(notifyFailureConfig);
                }

                return(Activator.CreateInstance(type));
            });

            var container = EntryPoint.CreateDependencyResolver(() => mockConfigurationFactory.Object);

            using (var scope = container.BeginLifetimeScope())
            {
                var orderProcessorFunctions = scope.Resolve <OrderSubmitterFunctions>();
                orderProcessorFunctions.Should().NotBeNull("because the Order Submitter WebJob functions should be resolvable");
            }
        }