Ejemplo n.º 1
0
        async Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage, BasicDeliverEventArgs> assertion)
        {
            var operations = builder.SendTo(queueToReceiveOn).Build();

            await messageDispatcher.Dispatch(operations, new TransportTransaction(), new ContextBag());

            var messageId = operations.MulticastTransportOperations.FirstOrDefault()?.Message.MessageId ?? operations.UnicastTransportOperations.FirstOrDefault()?.Message.MessageId;

            var result = Consume(messageId, queueToReceiveOn);

            var converter          = new MessageConverter();
            var convertedHeaders   = converter.RetrieveHeaders(result);
            var convertedMessageId = converter.RetrieveMessageId(result, convertedHeaders);

            var incomingMessage = new IncomingMessage(convertedMessageId, convertedHeaders, result.Body.ToArray());

            assertion(incomingMessage, result);
        }
        async Task Verify(OutgoingMessageBuilder builder, Action <IncomingMessage, BasicDeliverEventArgs> assertion, string queueToReceiveOn = "testEndPoint")
        {
            var operations = builder.SendTo(queueToReceiveOn).Build();

            MakeSureQueueAndExchangeExists(queueToReceiveOn);

            await messageDispatcher.Dispatch(operations, new TransportTransaction(), new ContextBag());

            var messageId = operations.MulticastTransportOperations.FirstOrDefault()?.Message.MessageId ?? operations.UnicastTransportOperations.FirstOrDefault()?.Message.MessageId;

            var result = Consume(messageId, queueToReceiveOn);

            var converter = new MessageConverter();

            var incomingMessage = new IncomingMessage(
                converter.RetrieveMessageId(result),
                converter.RetrieveHeaders(result),
                result.Body
                );

            assertion(incomingMessage, result);
        }