Esempio n. 1
0
        public void RegisterRabbitMQ_BuilderNullInput_ArgumentNullException()
        {
            //Arrange
            IAMQPBuilder builder = null;

            //Act
            var action = new Action(() => builder.Build());

            //Assert
            Assert.Throws <ArgumentNullException>(nameof(builder), action);
        }
Esempio n. 2
0
        /// <summary>
        /// Register a RabbitMQ message broker implementation. Make sure this is called last.
        /// </summary>
        /// <param name="builder">The <see cref="IAMQPBuilder"/> containing the <see cref="IServiceCollection"/> to register to.</param>
        public static void Build(this IAMQPBuilder builder)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (string.IsNullOrWhiteSpace(builder.ConnectionString))
            {
                throw new ArgumentException("The AMQPBuilder does not have a valid connection string.", nameof(builder));
            }

            builder.Services.AddTransient <IConnectionFactory>((sp) => new RabbitMQConnectionFactory(builder.ConnectionString));
        }