public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, BasicPublishAction = (exchangeName, topic, properties, messageBody) => { publishedToExchangeName = exchangeName; publishedToTopic = topic; } }; var customConventions = new Conventions { ExchangeNamingConvention = x => "CustomExchangeNamingConvention", QueueNamingConvention = (x, y) => "CustomQueueNamingConvention", TopicNamingConvention = x => "CustomTopicNamingConvention" }; CreateBus(customConventions, mockModel); using (var publishChannel = bus.OpenPublishChannel()) { publishChannel.Publish(new TestMessage()); } }
public void SetUp() { model = new MockModel(); bus = new TestBusFactory { Model = model, GetCorrelationId = () => correlationId }.CreateBusWithMockAmqpClient(); }
public void SetUp() { model = new MockModel { BasicPublishAction = (a,b,c,d) => { } }; var busFactory = new TestBusFactory(); bus = busFactory.CreateBusWithMockAmqpClient(); ((MockConnection) busFactory.Connection).CreateModelAction = () => { Console.Out.WriteLine("Creating Model"); return model; }; }
public void SetUp() { model = new MockModel { BasicPublishAction = (a, b, c, d) => { } }; var busFactory = new TestBusFactory(); bus = busFactory.CreateBusWithMockAmqpClient(); ((MockConnection)busFactory.Connection).CreateModelAction = () => { Console.Out.WriteLine("Creating Model"); return(model); }; }
public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, QueueDeclareAction = (queue, durable, exclusive, autoDelete, arguments) => { createdQueueName = queue; return(new QueueDeclareOk(queue, 0, 0)); } }; var customConventions = new Conventions { ErrorQueueNamingConvention = () => "CustomEasyNetQErrorQueueName", ErrorExchangeNamingConvention = (originalRoutingKey) => "CustomErrorExchangePrefixName." + originalRoutingKey }; errorStrategy = new DefaultConsumerErrorStrategy(new MockConnectionFactory(new MockConnection(mockModel)), new JsonSerializer(), new MockLogger(), customConventions); const string originalMessage = ""; var originalMessageBody = Encoding.UTF8.GetBytes(originalMessage); var deliverArgs = new BasicDeliverEventArgs { RoutingKey = "originalRoutingKey", Exchange = "orginalExchange", Body = originalMessageBody, BasicProperties = new BasicProperties { CorrelationId = string.Empty, AppId = string.Empty } }; try { errorStrategy.HandleConsumerError(deliverArgs, new Exception()); } catch (Exception exc) { // swallow } }
public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, BasicConsumeAction = (queue, noAck, consumerTag, consumer) => { return(string.Empty); }, QueueBindAction = (queue, exchange, routingKey) => { routingKeyName = routingKey; queueName = queue; } }; var customConventions = new Conventions { RpcExchangeNamingConvention = () => "CustomRpcExchangeName", RpcRoutingKeyNamingConvention = messageType => "CustomRpcRoutingKeyName" }; CreateBus(customConventions, mockModel); bus.Respond <TestMessage, TestMessage>(t => { return(new TestMessage()); }); }
public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, BasicPublishAction = (exchangeName, topic, properties, messageBody) => { publishedToExchangeName = exchangeName; publishedToTopic = topic; } }; var customConventions = new Conventions { ExchangeNamingConvention = x => "CustomExchangeNamingConvention", QueueNamingConvention = (x, y) => "CustomQueueNamingConvention", TopicNamingConvention = x => "CustomTopicNamingConvention" }; CreateBus(customConventions, mockModel); bus.Publish(new TestMessage()); }
public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, QueueDeclareAction = (queue, durable, exclusive, autoDelete, arguments) => { createdQueueName = queue; return new QueueDeclareOk(queue, 0, 0); } }; var customConventions = new Conventions { ErrorQueueNamingConvention = () => "CustomEasyNetQErrorQueueName", ErrorExchangeNamingConvention = (originalRoutingKey) => "CustomErrorExchangePrefixName." + originalRoutingKey }; errorStrategy = new DefaultConsumerErrorStrategy(new MockConnectionFactory(new MockConnection(mockModel)), new JsonSerializer(), new MockLogger(), customConventions); const string originalMessage = ""; var originalMessageBody = Encoding.UTF8.GetBytes(originalMessage); var deliverArgs = new BasicDeliverEventArgs { RoutingKey = "originalRoutingKey", Exchange = "orginalExchange", Body = originalMessageBody, BasicProperties = new BasicProperties { CorrelationId = string.Empty, AppId = string.Empty } }; try { errorStrategy.HandleConsumerError(deliverArgs, new Exception()); } catch (Exception exc) { // swallow } }
public void SetUp() { var mockModel = new MockModel { ExchangeDeclareAction = (exchangeName, type, durable, autoDelete, arguments) => createdExchangeName = exchangeName, BasicConsumeAction = (queue, noAck, consumerTag, consumer) => { return string.Empty; }, QueueBindAction = (queue, exchange, routingKey) => { routingKeyName = routingKey; queueName = queue; } }; var customConventions = new Conventions { RpcExchangeNamingConvention = () => "CustomRpcExchangeName", RpcRoutingKeyNamingConvention = messageType => "CustomRpcRoutingKeyName" }; CreateBus(customConventions, mockModel); bus.Respond<TestMessage, TestMessage>(t => { return new TestMessage(); }); }