public void When_sending_message_class_should_set_class_as_message_type()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);

            MessageOperations.Send <MyMessage>(context, m => { }, new SendOptions());

            Assert.That(sendPipeline.ReceivedContext.Message.MessageType, Is.EqualTo(typeof(MyMessage)));
        }
        public void When_sending_should_generate_message_id_and_set_message_id_header()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);

            MessageOperations.Send <MyMessage>(context, m => { }, new SendOptions());

            var messageId = sendPipeline.ReceivedContext.MessageId;

            Assert.IsNotNull(messageId);
            Assert.AreEqual(messageId, sendPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
        public void When_sending_with_user_defined_message_id_should_set_defined_id_and_header()
        {
            const string expectedMessageID = "expected message id";

            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);
            var sendOptions  = new SendOptions();

            sendOptions.SetMessageId(expectedMessageID);

            MessageOperations.Send <MyMessage>(context, m => { }, sendOptions);

            Assert.AreEqual(expectedMessageID, sendPipeline.ReceivedContext.MessageId);
            Assert.AreEqual(expectedMessageID, sendPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
        public void When_sending_should_clone_headers()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);
            var sendOptions  = new SendOptions();

            sendOptions.SetHeader("header1", "header1 value");

            MessageOperations.Send <MyMessage>(context, m => { }, sendOptions);
            sendPipeline.ReceivedContext.Headers.Add("header2", "header2 value");
            sendPipeline.ReceivedContext.Headers["header1"] = "updated header1 value";

            var optionsHeaders = sendOptions.GetHeaders();

            Assert.AreEqual(1, optionsHeaders.Count);
            Assert.AreEqual("header1 value", optionsHeaders["header1"]);
        }