private FluentRabbitConfiguration GetFluentRabbitConfiguration(string methodName = null) { methodName = methodName ?? MethodBase.GetCurrentMethod().Name; var exchangeName = $"Exchange_{methodName}_{Guid.NewGuid()}"; var queueName = $"Queue_{methodName}_{Guid.NewGuid()}"; var routingKey = $"RoutingKey_{methodName}_{Guid.NewGuid()}"; var config = new FluentRabbitConfiguration(); config.Exchanges.Add( p => { p.Name = exchangeName; }); config.Queues.Add( p => { p.Name = queueName; p.Config.Durable = true; p.Config.Arguments.Add("x-dead-letter-exchange", exchangeName + ".Deadletter"); }); config.Bindings.Add( p => { p.Config.ExchangeName = exchangeName; p.Config.QueueName = queueName; p.Config.RoutingKey = routingKey; }); return(config); }
public void AddExchange_Should_add_exchange_and_set_new_values() { var config = new FluentRabbitConfiguration(); config.Exchanges.Add( p => { p.Name = "Exchange1"; }); config.Exchanges.Should().ContainSingle(p => p.Name == "Exchange1"); }
public void AddExchange_Should_override_same_names() { var config = new FluentRabbitConfiguration(); config.Exchanges.Add( p => { p.Name = "Exchange1"; p.Config = new CreateExchangeConfig(); }); config.Exchanges.Add( p => { p.Name = "Exchange1"; p.Config = new CreateExchangeConfig(); }); config.Exchanges.Should().ContainSingle(p => p.Name == "Exchange1"); }
/// <summary> /// Configures the specified configuration. /// </summary> /// <param name="config">The configuration.</param> /// <returns></returns> public virtual IFluentRabbit Configure(FluentRabbitConfiguration config) { return(TryCatch_Trace(MethodBase.GetCurrentMethod(), () => { //validate config.ThrowExceptionIfNull <ArgumentNullException>(nameof(config)); //execute Configuration = config; })); }