Exemplo n.º 1
0
    static void Main(string[] args)
    {
        var x = new TestSource();
        var y = new TestDestination();

        x.Bind <string, string>(Name => y.Id);
    }
Exemplo n.º 2
0
        public void ConvertToMqMessage_CorrectBytesMessage_CorrectResult()
        {
            var reply   = new TestDestination();
            var session = new Mock <ISession>();

            session.Setup(x => x.CreateBytesMessage())
            .Returns(new BytesMessage());
            session.Setup(x => x.CreateQueue(It.IsAny <string>()))
            .Returns(reply);
            var message = new Messaging.Messages.BytesMessage
            {
                Body          = new byte[] { 97, 98, 99 },
                MessageId     = "abc",
                CorrelationId = "def",
                LifeTime      = TimeSpan.FromMinutes(10),
                ReplyQueue    = "Reply",
                Properties    = { { "Prop1", 12 }, { "Prop2", "def" } }
            };

            var result = message.ConvertToMqMessage(session.Object);

            Assert.Multiple(() =>
            {
                var bytesMessage = (BytesMessage)result;
                var bytes        = new byte[3];
                bytesMessage.ReadBytes(bytes);
                Assert.That(bytes[0] == 97);
                Assert.That(bytes[1] == 98);
                Assert.That(bytes[2] == 99);
                Assert.That(bytesMessage.JMSMessageID == "abc");
                Assert.That(bytesMessage.JMSExpiration == 6000);
                Assert.That(bytesMessage.JMSCorrelationID == "def");
                Assert.That(bytesMessage.JMSReplyTo, Is.EqualTo(reply));
                var prop1 = bytesMessage.Properties.First();
                var prop2 = bytesMessage.Properties.Last();
                Assert.That(prop1.Key == "Prop1");
                Assert.That(prop1.Value, Is.EqualTo(12));
                Assert.That(prop2.Key == "Prop2");
                Assert.That(prop2.Value, Is.EqualTo("def"));
            });
        }