public async Task ServiceBusMessagePump_PublishServiceBusMessage_MessageSuccessfullyProcessed()
        {
            // Arrange
            var config = TestConfig.Create();
            const ServiceBusEntity entity = ServiceBusEntity.Queue;

            var commandArguments = new[]
            {
                CommandArgument.CreateSecret("EVENTGRID_TOPIC_URI", config.GetTestInfraEventGridTopicUri()),
                CommandArgument.CreateSecret("EVENTGRID_AUTH_KEY", config.GetTestInfraEventGridAuthKey()),
                CommandArgument.CreateSecret("ARCUS_SERVICEBUS_CONNECTIONSTRING", config.GetServiceBusConnectionString(entity)),
            };

            using (var project = await ServiceBusWorkerProject.StartNewWithAsync <ServiceBusQueueProgram>(config, _outputWriter, commandArguments))
            {
                await using (var service = await TestMessagePumpService.StartNewAsync(entity, config, _outputWriter))
                {
                    // Act / Assert
                    await service.SimulateMessageProcessingAsync();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="entityName">Name of the entity to process</param>
        /// <param name="subscriptionPrefix">Name prefix of the subscription to process</param>
        /// <param name="serviceBusEntity">Entity type of the Service Bus</param>
        /// <param name="getConnectionStringFromConfigurationFunc">Function to look up the connection string from the configuration</param>
        /// <param name="getConnectionStringFromSecretFunc">Function to look up the connection string from the secret store</param>
        /// <param name="options">Options that influence the behavior of the message pump</param>
        /// <param name="serviceProvider">Collection of services to use</param>
        public AzureServiceBusMessagePumpSettings(
            string entityName,
            string subscriptionPrefix,
            ServiceBusEntity serviceBusEntity,
            Func <IConfiguration, string> getConnectionStringFromConfigurationFunc,
            Func <ISecretProvider, Task <string> > getConnectionStringFromSecretFunc,
            AzureServiceBusMessagePumpOptions options,
            IServiceProvider serviceProvider)
        {
            Guard.For <ArgumentException>(
                () => getConnectionStringFromConfigurationFunc == null && getConnectionStringFromSecretFunc == null,
                "Unable to determine connection string as it was not defined how to look it up");
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(serviceProvider, nameof(serviceProvider));

            _serviceProvider = serviceProvider;
            _getConnectionStringFromConfigurationFunc = getConnectionStringFromConfigurationFunc;
            _getConnectionStringFromSecretFunc        = getConnectionStringFromSecretFunc;

            EntityName         = entityName;
            SubscriptionPrefix = subscriptionPrefix;
            ServiceBusEntity   = serviceBusEntity;
            Options            = options;
        }
Ejemplo n.º 3
0
        public async Task GetHealthOfServiceBusProject_WithExcludeSerilog_ResponseHealthy(ServiceBusEntity resourceEntity)
        {
            // Arrange
            var config  = TestConfig.Create();
            var options =
                ServiceBusWorkerProjectOptions
                .Create(config).WithExcludeSerilog();

            using (var project = await ServiceBusWorkerProject.StartNewAsync(resourceEntity, config, options, _outputWriter))
            {
                // Act
                HealthStatus status = await project.Health.ProbeHealthAsync();

                // Assert
                Assert.Equal(HealthStatus.Healthy, status);
            }
        }