Exemplo n.º 1
0
        public void WhenMessageSentWithBodyWhichCannotBeDeserialized_MessageIsDeadlettered()
        {
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);

            writer.Write("{ ; }");
            writer.Flush();
            stream.Position = 0;

            var tm = new DeadLetterTransportMessage {
                MessageType = typeof(Message).AssemblyQualifiedName
            };

            tm.SetBody(stream);

            Func <Task> action = () => this.receiver.HandOver(tm);

            action.ShouldThrow <SerializationException>();
            tm.DeadLetterHeaders.Should().NotBeEmpty();
        }
        public void WhenMessageReachesMaximumNumberOfRetries_MessageIsDeadlettered()
        {
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);

            writer.Write("{ Bar: 1 }");
            writer.Flush();
            stream.Position = 0;

            var tm = new DeadLetterTransportMessage {
                MessageType = typeof(Message).AssemblyQualifiedName
            };

            tm.SetBody(stream);

            Func <Task> action = () => this.receiver.HandOver(tm);

            action.ShouldThrow <InvalidOperationException>();
            tm.DeadLetterHeaders.Should().NotBeEmpty();
        }
Exemplo n.º 3
0
        public void WhenMessageHandlerThrowsDeadletterMessageImmediatelyException_MessageIsDeadlettered()
        {
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);

            writer.Write("{ Bar: 1 }");
            writer.Flush();
            stream.Position = 0;

            var tm = new DeadLetterTransportMessage {
                MessageType = typeof(DeadletterImmediatelyMessage).AssemblyQualifiedName
            };

            tm.SetBody(stream);

            Func <Task> action = () => this.receiver.HandOver(tm);

            action.ShouldThrow <DeadletterMessageImmediatelyException>();
            tm.DeadLetterHeaders.Should().NotBeEmpty();
            tm.DelayedDeliveryCount.Should().Be(0);
        }