void ExceptionHandlerTypeIsInitialized() { var services = new ServiceCollection(); var options = new EventingOptions(services); Assert.Equal(typeof(DefaultEventingExceptionHandler), options.ExceptionHandlerType); }
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); }
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); }
/// <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; }
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); }
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); }
/// <summary> /// Constructor. /// </summary> /// <param name="options">The <see cref="EventingOptions"/>.</param> public EasyNetQProvider(EventingOptions options) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); }
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); }
void ExceptionHandlerTypeIsInitialized() { var options = new EventingOptions(); Assert.Equal(typeof(DefaultEventingExceptionHandler), options.ExceptionHandlerType); }
/// <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)); }
public EventPublisher(IMediator mediator, EventingOptions options, IEventingExceptionHandler exceptionHandler) { _mediator = mediator; _options = options; _exceptionHandler = exceptionHandler; }