Exemplo n.º 1
0
        public void CanCreateEmptyAmqpPropertiesFromBasicProperites()
        {
            IBasicProperties basicProperties = A.Fake <IBasicProperties>();
            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromProperties(basicProperties);

            properties.Should().NotBeNull(because: "Builder can build empty properties");
        }
Exemplo n.º 2
0
        public void CanCreateEmptyHeadersFromAmqpProperties()
        {
            IAmqpProperties properties = A.Fake <IAmqpProperties>();
            var             sut        = new AmqpPropertyBuilder();

            IDictionary <string, string> headers = sut.BuildHeadersFromProperties(properties);

            headers.Should().NotBeNull(because: "Builder can build empty headers");
        }
Exemplo n.º 3
0
        public void CanCreateEmptyAmqpProperties()
        {
            IMessage message = A.Fake <IMessage>();
            var      sut     = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromHeaders(message.Headers);

            properties.Should().NotBeNull(because: "Builder can build empty properties");
        }
Exemplo n.º 4
0
        public void CanCreateHeadersWithReplyToFromAmqpProperties()
        {
            IAmqpProperties properties  = A.Fake <IAmqpProperties>();
            const string    headerValue = "some address";

            A.CallTo(() => properties.ReplyTo).Returns(headerValue);

            var sut = new AmqpPropertyBuilder();

            IDictionary <string, string> headers = sut.BuildHeadersFromProperties(properties);

            headers.Should().Contain(new KeyValuePair <string, string>(AmqpPropertyBuilder.ReplyTo, headerValue));

            headers.Should().NotBeNull(because: "builder can build correlation id from AmqpProperties");
        }
Exemplo n.º 5
0
        public void CanCreateHeadersWithContentTypeFromAmqpProperties()
        {
            IAmqpProperties properties  = A.Fake <IAmqpProperties>();
            const string    headerValue = "text/plain";

            A.CallTo(() => properties.ContentType).Returns(headerValue);

            var sut = new AmqpPropertyBuilder();

            IDictionary <string, string> headers = sut.BuildHeadersFromProperties(properties);

            headers.Should().Contain(new KeyValuePair <string, string>(AmqpPropertyBuilder.ContentType, headerValue));

            headers.Should().NotBeNull(because: "builder can build content type from AmqpProperties");
        }
Exemplo n.º 6
0
        public void CanCreateAmqpPropertiesWithReplyToFromBasicProperties()
        {
            IBasicProperties basicProperties = A.Fake <IBasicProperties>();
            const string     headerValue     = "some address";

            A.CallTo(() => basicProperties.ReplyTo).Returns(headerValue);

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromProperties(basicProperties);

            properties.ReplyTo.Should().Be(headerValue);

            properties.Should().NotBeNull(because: "builder can build replyto from BasicProperties");
        }
Exemplo n.º 7
0
        public void CanCreateAmqpPropertiesWithPersistentFromBasicProperties()
        {
            IBasicProperties basicProperties = A.Fake <IBasicProperties>();
            const string     headerValue     = "true";

            A.CallTo(() => basicProperties.Persistent).Returns(bool.Parse(headerValue));

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromProperties(basicProperties);

            properties.Persistent.Should().Be(bool.Parse(headerValue));

            properties.Should().NotBeNull(because: "builder can build persistent from BasicProperties");
        }
Exemplo n.º 8
0
        public void CanCreateAmqpPropertiesWithMessageIdFromBasicProperties()
        {
            IBasicProperties basicProperties = A.Fake <IBasicProperties>();
            const string     headerValue     = "100500";

            A.CallTo(() => basicProperties.MessageId).Returns(headerValue);

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromProperties(basicProperties);

            properties.MessageId.Should().Be(headerValue);

            properties.Should().NotBeNull(because: "builder can build message id from BasicProperties");
        }
Exemplo n.º 9
0
        public void CanCreateAmqpPropertiesWithContentTypeFromBasicProperites()
        {
            IBasicProperties basicProperties = A.Fake <IBasicProperties>();
            const string     headerValue     = "text/plain";

            A.CallTo(() => basicProperties.ContentType).Returns(headerValue);

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromProperties(basicProperties);

            properties.ContentType.Should().Be(headerValue);

            properties.Should().NotBeNull(because: "builder can build content type from BasicProperties");
        }
Exemplo n.º 10
0
        public void CanCreateAmqpPropertiesWithMessageId()
        {
            IMessage     message     = A.Fake <IMessage>();
            const string headerValue = "100500";

            A.CallTo(() => message.Headers)
            .Returns(new Dictionary <string, string> {
                { AmqpPropertyBuilder.MessageId, headerValue }
            });

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromHeaders(message.Headers);

            properties.MessageId.Should().Be(headerValue);

            properties.Should().NotBeNull(because: "builder can build message id from message headers");
        }
Exemplo n.º 11
0
        public void CanCreateAmqpPropertiesWithContentType()
        {
            IMessage     message     = A.Fake <IMessage>();
            const string headerValue = "text/plain";

            A.CallTo(() => message.Headers)
            .Returns(new Dictionary <string, string> {
                { AmqpPropertyBuilder.ContentType, headerValue }
            });

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromHeaders(message.Headers);

            properties.ContentType.Should().Be(headerValue);

            properties.Should().NotBeNull(because: "builder can build content type from message headers");
        }
Exemplo n.º 12
0
        public void CanCreateAmqpPropertiesWithPersistent()
        {
            IMessage     message     = A.Fake <IMessage>();
            const string headerValue = "true";

            A.CallTo(() => message.Headers)
            .Returns(new Dictionary <string, string> {
                { AmqpPropertyBuilder.Persistent, headerValue }
            });

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromHeaders(message.Headers);

            properties.Persistent.Should().Be(bool.Parse(headerValue));

            properties.Should().NotBeNull(because: "builder can build persistent from message headers");
        }
Exemplo n.º 13
0
        public void CanCreateAmqpPropertiesWithHeaderNotContainPresetHeaders()
        {
            IMessage message       = A.Fake <IMessage>();
            var      customHeaders = new Dictionary <string, string> {
                { "key1", "value1" }, { "key2", "value2" }
            };
            var allHeaders = new Dictionary <string, string>(customHeaders);

            allHeaders.Add(AmqpPropertyBuilder.ReplyTo, "some-address");
            allHeaders.Add(AmqpPropertyBuilder.ContentType, "some-address");

            A.CallTo(() => message.Headers).Returns(allHeaders);

            var sut = new AmqpPropertyBuilder();

            IAmqpProperties properties = sut.BuildPropertiesFromHeaders(message.Headers);

            properties.Headers.Should().BeEquivalentTo(customHeaders, because: "preset headers should be set to properties");
        }