public async Task CreateAsync_AccessRightsNotManage_DoesNotCreateQueue(AccessRights accessRights)
        {
            ServiceBusAccount account = new ServiceBusAccount();
            Mock <ITriggeredFunctionExecutor> mockExecutor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict);
            ServiceBusQueueListenerFactory    factory      = new ServiceBusQueueListenerFactory(account, "testqueue", mockExecutor.Object, accessRights, new ServiceBusConfiguration());

            IListener listener = await factory.CreateAsync(CancellationToken.None);

            Assert.NotNull(listener);
        }
        public async Task CreateAsync_Success()
        {
            var config  = new ServiceBusConfiguration();
            var account = new ServiceBusAccount(config);
            Mock <ITriggeredFunctionExecutor> mockExecutor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict);
            ServiceBusQueueListenerFactory    factory      = new ServiceBusQueueListenerFactory(account, "testqueue", mockExecutor.Object, config);

            IListener listener = await factory.CreateAsync(CancellationToken.None);

            Assert.NotNull(listener);
        }
        public Task <IListener> CreateListenerAsync(ListenerFactoryContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IListenerFactory factory = null;

            if (_queueName != null)
            {
                factory = new ServiceBusQueueListenerFactory(_account, _queueName, context.Executor, _config);
            }
            else
            {
                factory = new ServiceBusSubscriptionListenerFactory(_account, _topicName, _subscriptionName, context.Executor, _config);
            }
            return(factory.CreateAsync(context.CancellationToken));
        }
Пример #4
0
        public async Task CreateAsync_Success()
        {
            var configuration = new ConfigurationBuilder()
                                .AddEnvironmentVariables()
                                .Build();
            var config = new ServiceBusOptions
            {
                ConnectionString = configuration.GetWebJobsConnectionString("ServiceBus")
            };

            var messagingProvider = new MessagingProvider(new OptionsWrapper <ServiceBusOptions>(config));

            var account = new ServiceBusAccount(config, configuration);
            Mock <ITriggeredFunctionExecutor> mockExecutor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict);
            ServiceBusQueueListenerFactory    factory      = new ServiceBusQueueListenerFactory(account, "testqueue", mockExecutor.Object, config, messagingProvider);

            IListener listener = await factory.CreateAsync(CancellationToken.None);

            Assert.NotNull(listener);
        }
Пример #5
0
        public IFunctionDefinition CreateFunctionDefinition(IReadOnlyDictionary <string, IBinding> nonTriggerBindings,
                                                            IFunctionInvoker invoker, FunctionDescriptor functionDescriptor)
        {
            ITriggeredFunctionBinding <BrokeredMessage> functionBinding =
                new TriggeredFunctionBinding <BrokeredMessage>(_parameterName, this, nonTriggerBindings);
            ITriggeredFunctionInstanceFactory <BrokeredMessage> instanceFactory =
                new TriggeredFunctionInstanceFactory <BrokeredMessage>(functionBinding, invoker, functionDescriptor);
            IListenerFactory listenerFactory;

            if (_queueName != null)
            {
                listenerFactory = new ServiceBusQueueListenerFactory(_account, _queueName, instanceFactory);
            }
            else
            {
                listenerFactory = new ServiceBusSubscriptionListenerFactory(_account, _topicName, _subscriptionName,
                                                                            instanceFactory);
            }

            return(new FunctionDefinition(instanceFactory, listenerFactory));
        }
        public async Task <IListener> CreateListenerAsync(ListenerFactoryContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IListenerFactory factory = null;

            if (_queueName != null)
            {
                factory = new ServiceBusQueueListenerFactory(_account, _queueName, context.Executor, _options, _messagingProvider);
            }
            else
            {
                factory = new ServiceBusSubscriptionListenerFactory(_account, _topicName, _subscriptionName, context.Executor, _options, _messagingProvider);
            }
            _listener = (ServiceBusListener)(await factory.CreateAsync(context.CancellationToken));

            return(_listener);
        }