public void Should_be_able_to_serialize_basic_properties() { var originalProperties = new BasicProperties { AppId = "some app id", ClusterId = "cluster id", ContentEncoding = "content encoding", ContentType = "content type", CorrelationId = "correlation id", DeliveryMode = 4, Expiration = "expiration", MessageId = "message id", Priority = 1, ReplyTo = "abc", Timestamp = new AmqpTimestamp(123344044), Type = "Type", UserId = "user id", Headers = new Hashtable { { "one", "header one" }, { "two", "header two" } } }; var messageBasicProperties = new MessageBasicProperties(originalProperties); var binaryMessage = serializer.MessageToBytes(messageBasicProperties); var deserializedMessageBasicProperties = serializer.BytesToMessage <MessageBasicProperties>(binaryMessage); var newProperties = new BasicProperties(); deserializedMessageBasicProperties.CopyTo(newProperties); Func <BasicProperties, string> getPropertiesString = p => { var builder = new StringBuilder(); p.AppendPropertyDebugStringTo(builder); return(builder.ToString()); }; getPropertiesString(originalProperties).ShouldEqual(getPropertiesString(newProperties)); }
public void Should_be_able_to_serialize_basic_properties() { var originalProperties = new BasicProperties { AppId = "some app id", ClusterId = "cluster id", ContentEncoding = "content encoding", ContentType = "content type", CorrelationId = "correlation id", DeliveryMode = 4, Expiration = "expiration", MessageId = "message id", Priority = 1, ReplyTo = "abc", Timestamp = new AmqpTimestamp(123344044), Type = "Type", UserId = "user id", Headers = new Hashtable { {"one", "header one"}, {"two", "header two"} } }; var messageBasicProperties = new MessageBasicProperties(originalProperties); var binaryMessage = serializer.MessageToBytes(messageBasicProperties); var deserializedMessageBasicProperties = serializer.BytesToMessage<MessageBasicProperties>(binaryMessage); var newProperties = new BasicProperties(); deserializedMessageBasicProperties.CopyTo(newProperties); Func<BasicProperties, string> getPropertiesString = p => { var builder = new StringBuilder(); p.AppendPropertyDebugStringTo(builder); return builder.ToString(); }; getPropertiesString(originalProperties).ShouldEqual(getPropertiesString(newProperties)); }
public void TestSimpleProperties() { RabbitMQ.Client.Framing.v0_8.BasicProperties prop = new RabbitMQ.Client.Framing.v0_8.BasicProperties(); prop.ContentType = "text/plain"; prop.WriteTo(m_w.BaseWriter, 0x123456789ABCDEF0UL); Check(m_w, new byte[] { 0x00, 0x00, // weight 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, // body len 0x80, 0x00, // props flags 0x0A, // shortstr len 0x74, 0x65, 0x78, 0x74, 0x2F, 0x70, 0x6C, 0x61, 0x69, 0x6E }); }
public void TestBodyLength() { RabbitMQ.Client.Framing.v0_8.BasicProperties prop = new RabbitMQ.Client.Framing.v0_8.BasicProperties(); prop.WriteTo(m_w.BaseWriter, 0x123456789ABCDEF0UL); Check(m_w, new byte[] { 0x00, 0x00, // weight 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, // body len 0x00, 0x00}); // props flags }