void ExceptionHandlerTypeIsInitialized()
        {
            var services = new ServiceCollection();
            var options  = new EventingOptions(services);

            Assert.Equal(typeof(DefaultEventingExceptionHandler), options.ExceptionHandlerType);
        }
コード例 #2
0
        void ExceptionHandlerTypeIsRegistered()
        {
            var options = new EventingOptions();

            options.RegisterExceptionHandler <TestExceptionHandler>();
            Assert.Equal(typeof(TestExceptionHandler), options.ExceptionHandlerType);
        }
        void ExceptionHandlerTypeIsRegistered()
        {
            var services = new ServiceCollection();
            var options  = new EventingOptions(services);

            options.RegisterExceptionHandler <TestExceptionHandler>();
            Assert.Equal(typeof(TestExceptionHandler), options.ExceptionHandlerType);
        }
コード例 #4
0
        public void PropertyConnectingStringTest()
        {
            var options = new EventingOptions
            {
                Host     = "host",
                VHost    = "vhost",
                Username = "******",
                Password = "******"
            };

            Assert.AreEqual($"amqp://{options.Username}:{options.Password}@{options.Host}:{options.Port}{options.VHost}", options.ConnectionString);
        }
コード例 #5
0
ファイル: EasyNetQProvider.cs プロジェクト: TheSpy/Nano
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/>.</param>
        /// <param name="options">The <see cref="EventingOptions"/>.</param>
        public EasyNetQProvider(ILogger logger, EventingOptions options)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            this.Logger  = logger;
            this.Options = options;
        }
コード例 #6
0
        public void DefaultValuesTest()
        {
            var options = new EventingOptions();

            Assert.IsNull(options.Host);
            Assert.AreEqual("/", options.VHost);
            Assert.AreEqual(string.Empty, options.Username);
            Assert.AreEqual(string.Empty, options.Password);
            Assert.AreEqual(5672, options.Port);
            Assert.AreEqual(30, options.Timeout);
            Assert.AreEqual(false, options.UseSsl);
            Assert.AreEqual(0, options.Heartbeat);
            Assert.AreEqual(true, options.UseHealthCheck);
            Assert.AreEqual($"amqp://{options.Username}:{options.Password}@{options.Host}:{options.Port}{options.VHost}", options.ConnectionString);
        }
コード例 #7
0
        public static IServiceCollection AddEventing(this IServiceCollection services, Action <EventingOptions> setupAction = null)
        {
            services.AddScoped <IMediator, Mediator>();
            services.AddScoped <IEventPublisher, EventPublisher>();

            services.AddScoped <SingleInstanceFactory>(p => t => p.GetRequiredService(t));
            services.AddScoped <MultiInstanceFactory>(p => t => p.GetRequiredServices(t));

            if (setupAction != null)
            {
                services.Configure(setupAction);
                var options = new EventingOptions();
                setupAction.Invoke(options);

                var handlerType = options.ExceptionHandlerType ?? typeof(DefaultEventingExceptionHandler);
                services.AddScoped(typeof(IEventingExceptionHandler), handlerType);
            }

            return(services);
        }
コード例 #8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="options">The <see cref="EventingOptions"/>.</param>
 public EasyNetQProvider(EventingOptions options)
 {
     this.Options = options ?? throw new ArgumentNullException(nameof(options));
 }
コード例 #9
0
        private static IServiceCollection AddEventingHealthChecks <TProvider>(this IServiceCollection services, EventingOptions options)
            where TProvider : class, IEventingProvider
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (!options.UseHealthCheck)
            {
                return(services);
            }

            if (typeof(TProvider) == typeof(EasyNetQProvider))
            {
                services
                .AddHealthChecks()
                .AddRabbitMQ(rabbitConnectionString: options.ConnectionString);
            }

            return(services);
        }
コード例 #10
0
        void ExceptionHandlerTypeIsInitialized()
        {
            var options = new EventingOptions();

            Assert.Equal(typeof(DefaultEventingExceptionHandler), options.ExceptionHandlerType);
        }
コード例 #11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="services">The <see cref="IServiceCollection"/>.</param>
 /// <param name="options">The <see cref="EventingOptions"/>.</param>
 public EasyNetQProvider(IServiceCollection services, EventingOptions options)
 {
     this.Services = services ?? throw new ArgumentNullException(nameof(services));
     this.Options  = options ?? throw new ArgumentNullException(nameof(options));
 }
コード例 #12
0
 public EventPublisher(IMediator mediator, EventingOptions options, IEventingExceptionHandler exceptionHandler)
 {
     _mediator         = mediator;
     _options          = options;
     _exceptionHandler = exceptionHandler;
 }