public async Task RunTest()
        {
            EndpointConvention.Map <B>(InputQueueAddress);

            var sendObserver = new TestSendObserver(TimeSpan.FromSeconds(3));

            using (InputQueueSendEndpoint.ConnectSendObserver(sendObserver))
            {
                await InputQueueSendEndpoint.Send(new A());

                ISentMessage <A> a = sendObserver.Messages.Select <A>().FirstOrDefault();
                ISentMessage <B> b = sendObserver.Messages.Select <B>().FirstOrDefault();

                a.ShouldNotBeNull();
                b.ShouldNotBeNull();

                Dictionary <string, object> ah = a.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);
                Dictionary <string, object> bh = b.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);

                ah.ShouldContainKey("x-send-filter");
                ah.ShouldContainKey("x-send-message-filter");
                ah["x-send-filter"].ShouldBe("send-filter");
                ah["x-send-message-filter"].ShouldBe("send-message-filter");

                bh.ShouldContainKey("x-send-filter");
                bh.ShouldContainKey("x-send-message-filter");

                // those fails, as while they DO have ",has-consume-context" they don't have access to SomePayload
                bh["x-send-filter"].ShouldBe("send-filter,has-consume-context,has-some-payload:hello");
                bh["x-send-message-filter"].ShouldBe("send-message-filter,has-consume-context,has-some-payload:hello");
            }
        }
Пример #2
0
        public async Task Should_invoke_the_observer_prior_to_send()
        {
            var observer = new Observer();

            using (InputQueueSendEndpoint.ConnectSendObserver(observer))
            {
                await InputQueueSendEndpoint.Send(new PingMessage());

                await observer.PreSent;
            }
        }
Пример #3
0
        public async Task Should_invoke_the_exception_after_send_failure()
        {
            var observer = new Observer();

            using (InputQueueSendEndpoint.ConnectSendObserver(observer))
            {
                Assert.Throws <SerializationException>(async() => await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(x => x.Serializer = null)));

                await observer.SendFaulted;
            }
        }
Пример #4
0
        public async Task Should_not_invoke_post_sent_on_exception()
        {
            var observer = new Observer();

            using (InputQueueSendEndpoint.ConnectSendObserver(observer))
            {
                Assert.Throws <SerializationException>(async() => await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(x => x.Serializer = null)));

                await observer.SendFaulted;

                observer.PostSent.Status.ShouldBe(TaskStatus.WaitingForActivation);
            }
        }
Пример #5
0
            public async Task Should_invoke_the_observer_prior_to_send()
            {
                var observer = new SendObserver(this);

                using (InputQueueSendEndpoint.ConnectSendObserver(observer))
                {
                    await InputQueueSendEndpoint.Send(new PingMessage());

                    await observer.PreSent;

                    Assert.That(observer.PreSentCount, Is.EqualTo(1));
                    Assert.That(observer.PostSentCount, Is.EqualTo(1));
                }
            }
Пример #6
0
            public async Task Should_invoke_the_exception_after_send_failure()
            {
                var observer = new SendObserver(this);

                using (InputQueueSendEndpoint.ConnectSendObserver(observer))
                {
                    Assert.That(async() => await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(x => x.Serializer = null)),
                                Throws.TypeOf <SerializationException>());

                    await observer.PreSent;
                    await observer.SendFaulted;
                    Assert.That(observer.PreSentCount, Is.EqualTo(1));
                    Assert.That(observer.SendFaultCount, Is.EqualTo(1));
                }
            }