public void BuildBasicProperties() { const String contentType = "application/xml"; const String contentEncoding = "UTF-16"; const String messageId = "one-id"; const Int64 timestamp = 123456789L; const String replyExchangeName = "reply-queue-name"; const String replyRoutingKey = "reply-queue-name"; String correlationId = Guid.NewGuid().ToString(); var directReplyConfiguration = new DirectReplyConfiguration(replyExchangeName, replyRoutingKey); var collection = new HeaderCollection(new Dictionary<String, Object>(StringComparer.OrdinalIgnoreCase) { { "message_id", messageId }, { "timestamp", timestamp }, { "content_type", contentType }, { "content_encoding", contentEncoding }, { "correlation_id", correlationId }, { "reply_configuration", directReplyConfiguration } }); const String key = "foo"; const String value = "bar"; collection.AddHeader(key, value); var resolver = new Mock<IMessageTypeResolver>(); resolver.Setup(_ => _.Resolve<Foo>()).Returns(EmptyMessageBinding.Instance); var message = new OutboundMessage<Foo>(new Foo(), collection); var properties = message.BuildBasicProperties(resolver.Object, null, null); Assert.Equal(messageId, properties.MessageId); Assert.Equal(new AmqpTimestamp(timestamp), properties.Timestamp); Assert.Equal(contentType, properties.ContentType); Assert.Equal(contentEncoding, properties.ContentEncoding); Assert.Equal(correlationId, properties.CorrelationId); Assert.Equal(directReplyConfiguration.ToString(), properties.ReplyTo); Assert.Equal(value, collection[key]); }
protected IBasicProperties BuildBasicProperties <TMessage>(OutboundMessage <TMessage> source) where TMessage : class { return(source.BuildBasicProperties(Configuration.MessageTypeResolver, DateTimeProvider, Configuration.IdGenerator)); }
public void BuildBasicPropertiesByConfiguration() { const String contentType = "application/json"; const String contentEncoding = "UTF-8"; const String messageId = "one-id"; const Int64 timestamp = 123456789L; var collection = new HeaderCollection(new Dictionary <String, Object>(StringComparer.OrdinalIgnoreCase) { { "content_type", contentType }, { "content_encoding", contentEncoding } }); const String key = "foo"; const String value = "bar"; collection.AddHeader(key, value); var resolver = new Mock <IMessageTypeResolver>(); resolver.Setup(_ => _.Resolve <Foo>()).Returns(EmptyMessageBinding.Instance); var newId = new Mock <INewId>(); newId.Setup(_ => _.Next()).Returns(messageId); var dateTimeProvider = new Mock <IDateTimeProvider>(); dateTimeProvider.Setup(_ => _.UtcNow()).Returns(timestamp.ToDateTimeOffset()); var message = new OutboundMessage <Foo>(new Foo(), collection); var properties = message.BuildBasicProperties(resolver.Object, dateTimeProvider.Object, newId.Object); Assert.Equal(messageId, properties.MessageId); Assert.Equal(new AmqpTimestamp(timestamp), properties.Timestamp); Assert.Equal(contentType, properties.ContentType); Assert.Equal(contentEncoding, properties.ContentEncoding); }
public void BuildBasicPropertiesByConfiguration() { const String contentType = "application/json"; const String contentEncoding = "UTF-8"; const String messageId = "one-id"; const Int64 timestamp = 123456789L; var collection = new HeaderCollection(new Dictionary<String, Object>(StringComparer.OrdinalIgnoreCase) { { "content_type", contentType }, { "content_encoding", contentEncoding } }); const String key = "foo"; const String value = "bar"; collection.AddHeader(key, value); var resolver = new Mock<IMessageTypeResolver>(); resolver.Setup(_ => _.Resolve<Foo>()).Returns(EmptyMessageBinding.Instance); var newId = new Mock<INewId>(); newId.Setup(_ => _.Next()).Returns(messageId); var dateTimeProvider = new Mock<IDateTimeProvider>(); dateTimeProvider.Setup(_ => _.UtcNow()).Returns(timestamp.ToDateTimeOffset()); var message = new OutboundMessage<Foo>(new Foo(), collection); var properties = message.BuildBasicProperties(resolver.Object, dateTimeProvider.Object, newId.Object); Assert.Equal(messageId, properties.MessageId); Assert.Equal(new AmqpTimestamp(timestamp), properties.Timestamp); Assert.Equal(contentType, properties.ContentType); Assert.Equal(contentEncoding, properties.ContentEncoding); }
public void BuildBasicProperties() { const String contentType = "application/xml"; const String contentEncoding = "UTF-16"; const String messageId = "one-id"; const Int64 timestamp = 123456789L; var collection = new HeaderCollection(new Dictionary <String, Object>(StringComparer.OrdinalIgnoreCase) { { "message_id", messageId }, { "timestamp", timestamp }, { "content_type", contentType }, { "content_encoding", contentEncoding } }); const String key = "foo"; const String value = "bar"; collection.AddHeader(key, value); var resolver = new Mock <IMessageTypeResolver>(); resolver.Setup(_ => _.Resolve <Foo>()).Returns(EmptyMessageBinding.Instance); var message = new OutboundMessage <Foo>(new Foo(), collection); var properties = message.BuildBasicProperties(resolver.Object, null, null); Assert.Equal(messageId, properties.MessageId); Assert.Equal(new AmqpTimestamp(timestamp), properties.Timestamp); Assert.Equal(contentType, properties.ContentType); Assert.Equal(contentEncoding, properties.ContentEncoding); Assert.Equal(value, collection[key]); }
public void NonDurableMessage() { var message = new OutboundMessage <Bar>(new Bar()); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.False(properties.Persistent); }
public void DefaultContentType() { var message = new OutboundMessage <Bar>(new Bar()); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal("application/json", properties.ContentType); }
public void DefaultContentEncoding() { var message = new OutboundMessage <Bar>(new Bar()); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal("UTF-8", properties.ContentEncoding); }
public void MessageType() { var message = new OutboundMessage <Bar>(new Bar()); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal("urn:message:fake", properties.Type); }
public void DirectReplyWithDefaultExchange() { const String replyRoutingKey = "replyRoutingKey"; var message = new OutboundMessage <Bar>(new Bar()); message.SetReply(new DirectReplyConfiguration(replyRoutingKey)); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal("direct:///replyRoutingKey", properties.ReplyTo); }
public void CorrelationId() { String correlationId = Guid.NewGuid().ToString(); var message = new OutboundMessage <Bar>(new Bar()); message.SetCorrelationId(correlationId); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal(correlationId, properties.CorrelationId); }
public void ContentType() { const String contentType = "application/xml"; var message = new OutboundMessage <Bar>(new Bar()); message.SetContentType(contentType); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal(contentType, properties.ContentType); }
public void ContentEncoding() { const String contentEncoding = "UTF-16"; var message = new OutboundMessage <Bar>(new Bar()); message.SetContentEncoding(contentEncoding); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal(contentEncoding, properties.ContentEncoding); }
public void FanoutReply() { const String replyExchangeName = "replyExchangeName"; var message = new OutboundMessage <Bar>(new Bar()); message.SetReply(new FanoutReplyConfiguration(replyExchangeName)); var properties = message.BuildBasicProperties(StubResolver <Bar>(null).Object, StubDateTimeProvider().Object, new Mock <INewId>().Object); Assert.Equal("fanout", properties.ReplyToAddress.ExchangeType); Assert.Equal(replyExchangeName, properties.ReplyToAddress.ExchangeName); Assert.Equal(String.Empty, properties.ReplyToAddress.RoutingKey); Assert.Equal("fanout://replyExchangeName/", properties.ReplyTo); }
public void BuildBasicProperties() { const String contentType = "application/xml"; const String contentEncoding = "UTF-16"; const String messageId = "one-id"; const Int64 timestamp = 123456789L; const String replyExchangeName = "reply-queue-name"; const String replyRoutingKey = "reply-queue-name"; var correlationId = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1).ToString(); var directReplyConfiguration = new DirectReplyConfiguration(replyExchangeName, replyRoutingKey); var collection = new HeaderCollection(new Dictionary <String, Object>(StringComparer.OrdinalIgnoreCase) { { "message_id", messageId }, { "timestamp", timestamp }, { "content_type", contentType }, { "content_encoding", contentEncoding }, { "correlation_id", correlationId }, { "reply_configuration", directReplyConfiguration } }); const String key = "foo"; const String value = "bar"; collection.AddHeader(key, value); var resolver = new Mock <IMessageTypeResolver>(); resolver.Setup(_ => _.Resolve <Foo>()).Returns(EmptyMessageBinding.Instance); var message = new OutboundMessage <Foo>(new Foo(), collection); var properties = message.BuildBasicProperties(resolver.Object, null, null); Assert.Equal(messageId, properties.MessageId); Assert.Equal(new AmqpTimestamp(timestamp), properties.Timestamp); Assert.Equal(contentType, properties.ContentType); Assert.Equal(contentEncoding, properties.ContentEncoding); Assert.Equal(correlationId, properties.CorrelationId); Assert.Equal(directReplyConfiguration.ToString(), properties.ReplyTo); Assert.Equal(value, collection[key]); }